【问题标题】:Mismatch in SQLite for node deployment to azure节点部署到天蓝色的 SQLite 不匹配
【发布时间】: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


【解决方案1】:

问题在于我的开发环境、部署环境和运行时环境之间的 nodejs 和 npm 版本不匹配。于是我分三步解决了:

1。查找可能的 node.js 版本

git push azure-prod master期间,我得到了信息:

remote: Node.js versions available on the platform are: 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.8.28, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29, 0.10.31, 0.10.32, 0.10.40, 0.12.0, 0.12.2, 0.12.3 ...

我从该列表中选择了一个节点版本。最新版本是8.10.0

2。查找对应的 npm 版本

我去了https://&lt;my-site&gt;.scm.azurewebsites.net/api/diagnostics/runtime 并获得了与此匹配的 npm 版本列表。匹配的版本是5.6.0

3。修复package.json

我写了

"engines": {
    "node": "8.10.0",
    "npm": "5.6.0"
}

在我的package.json

4。配置 Aure

虽然可能没有必要,但我还是选择了WEBSITE_NODE_DEFAULT_VERSION8.10.0

5。部署

最后的git push azure-prod master 让整个事情开始运转!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多