【发布时间】:2018-04-01 22:48:20
【问题描述】:
背景
我正在从本地 git 部署 node.js Web 应用程序。 Like in the tutorial。我已经成功部署了 hello-world 示例,并且成功了。
现在我想部署另一个版本的应用程序 - 它有很多新功能和依赖项。 package.json 包含其他
"engines": {
"node": ">=6.9.1"
},
"dependencies": {
"jsonschema": "^1.2.2",
"lodash": "^4.17.5",
"npm": "^5.8.0",
"sqlite3": "^4.0.0"
}
我的本地开发环境是
PS ...> node --version
v9.8.0
PS ...> npm --version
5.8.0
我已经在我的回购.\node_modules\sqlite3\lib\binding\node-v59-win32-x64 中提出了。
这在本地很有效!
问题
这一次当我部署到 Azure 时,它没有以前那么好用了。执行git push azure-prod master 时,我收到警告:
Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml
remote: .......................................
remote: npm WARN lifecycle The node binary used for scripts is D:\Program Files (x86)\nodejs\6.9.1\node.exe but npm is using D:\Program Files (x86)\nodejs\8.10.0\node.exe itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
remote:
remote: > sqlite3@4.0.0 install D:\home\site\wwwroot\node_modules\sqlite3
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: [sqlite3] Success: "D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v48-win32-ia32\node_sqlite3.node" is installed via remote
并尝试访问 Web 应用程序会生成 HTTP 500。Azure 上的应用程序日志显示
Error: Cannot find module 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v57-win32-ia32\node_sqlite3.node'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:\home\site\wwwroot\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
问题
如何将带有 nodejs 的 sqlite3 正确部署到 Azure Web Apps?
相关问题
http://codeclimber.net.nz/archive/2014/02/07/Why-is-a-32bit-Windows-Azure-WebSite-running-as-64bit/ 讨论一个类似的问题,但与架构不匹配(32 位与 64 位)有关。它还使用 kudu 控制台在部署后修补安装 - 在我看来,这似乎是一个次优修复。有没有更稳健的解决方案?
【问题讨论】:
-
我正在对 node/npm 版本进行故障排除。 Azure Web Apps 可用的节点环境与通过本地 git deploy 选项可用的节点/npm 版本之间似乎存在一些版本不匹配。目前正在降级到 Node 8.10.0...
标签: node.js azure sqlite azure-web-app-service