2

In order to do some image processing using the Node library, Sharp, I had to upgrade my node executable on Azure App Service to 64-bits. I did this by downloading the executable manually and then setting its path in IISNode.yml.

Unfortunately, when I start the app, it throws the following error:

Application has thrown an uncaught exception and is terminated: Error: %1 is not a valid Win32 application.

\\?\D:\home\site\wwwroot\node_modules\bcrypt\build\Release\bcrypt_lib.node
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at bindings (D:\home\site\wwwroot\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bcrypt\bcrypt.js:3:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.cls_wrapMethod [as _load] (D:\home\site\wwwroot\node_modules\newrelic\lib\shimmer.js:256:38)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\bookshelf-bcrypt\index.js:5:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

I'm building and deploying the application using the Appveyor CI system. Here's my the relevant portion of my appveyor.yml file:

install:
  - ps: Install-Product node $env:nodejs_version x64
  - SET CL=-DDELAYIMP_INSECURE_WRITABLE_HOOKS
  - npm i --loglevel=warn
  - npm prune --production
  - 7z a api.zip * -x!test -x!db -x!.git -xr!.* -x!README.md -x!nodemon.json -x!appveyor.yml | FIND /V "ing  "

You'll see that I'm building using a 64-bit version of Node.

On my Azure app service, I have the platform set to 64-bit.

Things I've tried:

  • Setting the platform to 32-bit on Azure
  • Blowing away node_modules/ on App Service

Thanks in advance!

4

1 に答える 1

5

Azure Web Apps の既定の node.js 実行アプリケーションはすべて 32 ビットです。だからそれはあなたの問題を提起します。カスタム node.js ランタイムを使用して、要件を達成できます。次の手順を試してください。

1. 64 ビットの node.exe 実行アプリケーションをアプリケーション内 (たとえば、runtimeフォルダー内) に配置します。

2、iisnode.yml設定を変更します。

nodeProcessCommandLine: "D:\home\site\wwwroot\runtime\node.exe"

3, アプリケーション全体を Azure Web Apps にデプロイします。

さらに、次のコードを使用して、node.js バイナリが有効かどうかを確認できますx64

var http = require("http");

http.createServer(function (request, response) {
    response.writeHead(200, { "Content-Type": "text/plain" });
    response.write(require('os').arch());
    response.end();

}).listen(process.env.PORT);

これが機能しない場合はお知らせください。

于 2016-11-24T06:54:44.173 に答える