为了使用 Node 库 Sharp 进行一些图像处理,我必须将 Azure 应用服务上的节点可执行文件升级到 64 位。我通过手动下载可执行文件然后将其路径设置为IISNode.yml
.
不幸的是,当我启动应用程序时,它会抛出以下错误:
应用程序抛出未捕获的异常并终止:
错误:%1 不是有效的 Win32 应用程序。
\\?\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)
我正在使用 Appveyor CI 系统构建和部署应用程序。这是我的相关部分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 "
您会看到我正在使用 64 位版本的 Node 进行构建。
在我的 Azure 应用程序服务上,我将平台设置为 64 位。
我尝试过的事情:
- 在 Azure 上将平台设置为 32 位
- 在应用服务上吹掉node_modules/
提前致谢!
Azure Web Apps 上的默认 Node.js 执行应用程序均为 32 位。所以这就提出了你的问题。我们可以使用自定义的node.js运行时来实现您的要求。请尝试以下步骤:
1、在你的应用程序中放置一个64位的node.exe执行应用程序,例如在一个runtime
folder.
2、修改iisnode.yml
, set:
nodeProcessCommandLine: "D:\home\site\wwwroot\runtime\node.exe"
3、将整个应用程序部署到Azure Web Apps。
此外,您可以使用以下代码来验证node.js二进制文件是否是x64
or not.
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);
如果这不起作用,请告诉我。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)