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

眉间皱痕 提交于 2019-12-11 03:38:38

问题


I used following in package.json when deploying to azure web site:

{
    "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. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with. Finished successfully.

How do I set this --scripts-prepend-node-path option when deploying to azure web sites?


回答1:


In your Azure App settings, try setting WEBSITE_NODE_DEFAULT_VERSION to 6.11.1 so it matches your engine spec. 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. Specifically, you'd look for a line that looks like call :ExecuteCmd !NPM_CMD! install --production and modify it whichever way you need.




回答2:


You can set this option by using npm config set scripts-prepend-node-path true when deploying to Azure.



来源:https://stackoverflow.com/questions/45384045/how-to-npm-configuration-options-such-as-scripts-prepend-node-path-when-depl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!