问题
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