【问题标题】:Azure node deployment - Service Unavailable - npm WARN lifecycleAzure 节点部署 - 服务不可用 - npm WARN 生命周期
【发布时间】:2018-03-06 17:15:51
【问题描述】:

我正在使用 git 将 node.js 应用程序部署到 Azure 应用程序服务。 它返回

服务不可用

在应用程序页面上。在控制台中显示

加载资源失败:服务器响应状态为 503 (服务暂时不可用)

在部署期间我收到一个警告:

npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/nodejs/8.1.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

我在 package.json 的脚本中包含了该选项,但它没有解决它,也许它是错误的地方?

"start": "node server/server.js --scripts-prepend-node-path"

我已经用谷歌搜索了答案,但无法解决。

How to npm configuration options (such as --scripts-prepend-node-path) when deploying to azure web sites?

在环境变量中将 WEBSITE_NODE_DEFAULT_VERSION 设置为 8.1.0 没有帮助。我在 package.json 中指定了这个节点版本。

如第二个提示所示,我无法执行自定义部署脚本。

我在项目文件夹中本地运行npm config set scripts-prepend-node-path true,然后推送,但没有解决。

其他一些答案表明可能需要扩展应用程序,但 Heroku 免费计划可以很好地处理这个应用程序,并且在 Azure 上我有一个学生计划。

我包含了我得到的日志的一部分:

Detecting node version spec...
Using package.json engines.node value: 8.1.0
Node.js versions available on the platform are: 4.4.7, 4.5.0, 6.2.2, 6.6.0, 6.9.3, 6.10.3, 6.11.0, 8.0.0, 8.1.0.
Resolved to version 8.1.0
Detecting npm version spec...
Using default for node 8.1.0: 5.0.3
NPM versions available on the platform are: 2.15.8, 2.15.9, 3.9.5, 3.10.3, 3.10.10, 5.0.3.
Resolved to version 5.0.3
Running "/opt/nodejs/8.1.0/bin/node" "/opt/npm/5.0.3/node_modules/npm/bin/npm-cli.js" install --production
npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/nodejs/8.1.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN node_code@1.0.0 No description
updated 17 packages in 29.222s
npm WARN node_code@1.0.0 No repository field.
Finished successfully.

在 Azure 上诊断应用程序导致:

失败的网址 50% 的失败来自“/favicon.ico”路径。

如果有人能帮我解决这个问题,我将不胜感激,我是此类部署的新手。如果我没有提供一些必要的数据,请告诉我。

谢谢

【问题讨论】:

    标签: node.js azure npm deployment


    【解决方案1】:

    根据我的理解,这与部署问题无关。 503 Service Unavailable 错误意味着该网站的服务器现在根本不可用。此问题通常是由应用程序级别的问题引起的,例如:

    • 请求需要很长时间
    • 应用程序使用高内存/CPU
    • 应用程序因异常而崩溃。

    您可以查看Azure's official documentation 以解决您的 Azure Web 应用程序中的“502 bad gateway”和“503 服务不可用”的 HTTP 错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多