简体   繁体   English

在部署到azure网站时如何npm配置选项(例如--scripts-prepend-node-path)?

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

I used following in package.json when deploying to azure web site: 在部署到azure网站时,我在package.json中使用了以下内容:

{
    "name": "mypackage",
    ...
    "engines": {
        "node": "6.11.1",
        "npm": "4.2.0"
    },
    ...
}

Everything worked fine but I also got following warning: 一切正常,但我也得到以下警告:

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\\6.11.1\\node.exe itself. npm WARN生命周期用于脚本的节点二进制文件是D:\\ Program Files(x86)\\ nodejs \\ 6.9.1 \\ node.exe但是npm使用的是D:\\ Program Files(x86)\\ nodejs \\ 6.11.1 \\ node.exe本身。 Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with. 使用--scripts-prepend-node-path选项包括执行npm的节点二进制文件的路径。 Finished successfully. 顺利完成。

How do I set this --scripts-prepend-node-path option when deploying to azure web sites? 在部署到azure网站时,如何设置此--scripts-prepend-node-path选项?

在部署到Azure时,可以使用npm config set scripts-prepend-node-path true设置此选项。

In your Azure App settings, try setting WEBSITE_NODE_DEFAULT_VERSION to 6.11.1 so it matches your engine spec. 在Azure应用程序设置中,尝试将WEBSITE_NODE_DEFAULT_VERSION设置为6.11.1以使其符合您的引擎规范。 Though I'm guessing the warning is mostly harmless. 虽然我猜这个警告大多是无害的。

Though the above should solve your issue, to more directly answer your question, you can add npm params by creating a Custom Deployment Script . 虽然以上内容可以解决您的问题,但是为了更直接地回答您的问题,您可以通过创建自定义部署脚本来添加npm params。 Specifically, you'd look for a line that looks like call :ExecuteCmd !NPM_CMD! install --production 具体来说,你会找到一个看起来像call :ExecuteCmd !NPM_CMD! install --production call :ExecuteCmd !NPM_CMD! install --production and modify it whichever way you need. call :ExecuteCmd !NPM_CMD! install --production并根据您的需要进行修改。

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

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