简体   繁体   English

我无法更改 Azure 中的节点版本

[英]I can't change the version of node in Azure

I'm running the node server on Azure and need to change the default version of node because it's 0.8.28, or to set the specific version for the app.我在 Azure 上运行节点服务器,需要更改节点的默认版本,因为它是 0.8.28,或者为应用程序设置特定版本。

At the first time, I thought that I can specify the version using deployment file (deploy.cmd) and package.json like following;第一次,我认为我可以使用部署文件(deploy.cmd)和 package.json 指定版本,如下所示;

deploy.cmd部署命令

:: Force use of the latest NPM
SET NPM_JS_PATH=%ProgramFiles(x86)%\npm\6.12.0\node_modules\npm\bin\npm-cli.js
SET NODE_PATH=%ProgramFiles(x86)%\nodejs\8.9.4\node.exe

package.json包.json

"engines": {
  "node": "8.9.4",
  "npm": "6.12.0"
},

And when the app is deployed, it shows specified versions are set.部署应用程序时,它会显示已设置指定的版本。

2019-12-05T15:36:17    Selected node.js version 8.9.4. Use package.json file to choose a different version.
2019-12-05T15:36:17    Selected npm version 6.12.0
2019-12-05T15:36:17    Updating iisnode.yml at D:\home\site\wwwroot\App_Data\config\scripts\iisnode.yml

That's why I expected the app will be running on node@8.9.4 but when i consoled process.version , it's still 0.8.28.这就是为什么我希望应用程序将在 node@8.9.4 上运行,但是当我安慰process.version 时,它仍然是 0.8.28。 It looks like the version is being overwritten by default version at the end when it's deployed.看起来版本在部署时最后被默认版本覆盖。

Additionally, I tried to edit WEBSITE_NODE_DEFAULT_VERSION variable in Configuration (Settings > Configuration > WEBSITE_NODE_DEFAULT_VERSION) but I couldn't save because the host name doesn't include "azurewebsites.net".此外,我尝试在配置(设置 > 配置 > WEBSITE_NODE_DEFAULT_VERSION)中编辑 WEBSITE_NODE_DEFAULT_VERSION 变量,但我无法保存,因为主机名不包含“azurewebsites.net”。

Is there any way to specify the node version or edit WEBSITE_NODE_DEFAULT_VERSION?有没有办法指定节点版本或编辑WEBSITE_NODE_DEFAULT_VERSION?

Node Version for your app Kudu needs to know which version of node you want to run your app and deployment.您的应用程序的节点版本 Kudu 需要知道您要运行应用程序和部署的节点版本。 It will try to find the version you want by following these steps.它将尝试按照以下步骤找到您想要的版本。 If not satisfied, goes to the next step:如果不满意,进入下一步:

  1. If there is an iisnode.yml and nodeProcessCommandLine property inside: it will run that exact path of node.如果里面有 iisnode.yml 和 nodeProcessCommandLine 属性:它将运行节点的确切路径。
  2. If in your package.json, there is an "engines":{"node":version} specification, Azure will use the specified version如果在你的 package.json 中有一个 "engines":{"node":version} 规范,Azure 将使用指定的版本
  3. In Application Settings on the Azure portal, you have WEBSITE_NODE_DEFAULT_VERSION set as one of the environment variables在 Azure 门户上的应用程序设置中,您将 WEBSITE_NODE_DEFAULT_VERSION 设置为环境变量之一
  4. The default Node version for Azure. Azure 的默认节点版本。 The exact version changes over time.确切的版本随着时间的推移而变化。

I think iisnode.yml does not have node version which you require.create iisnode.yml and include below line我认为iisnode.yml没有您需要的节点版本。创建 iisnode.yml 并包含以下行

nodeProcessCommandLine: "D:\\Program Files (x86)\\nodejs\\8.9.4\\node.exe"

More deatils read here:更多细节在这里阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM