[英]Node.js app - different NODE_ENV when launched by NPM
I have a node.js app.我有一个node.js应用程序。 It runs in the "production" mode when it was launched by the npm start
and in the 'development' mode when it was launched by node start.js
.它在由npm start
时以“生产”模式运行,当它由node start.js
时以“开发”模式运行。 I don't understand the difference.我不明白其中的区别。
How can I set the 'development' mode according the system variable also for the 'npm start'?如何根据系统变量也为“npm start”设置“开发”模式?
Inside the script I log the value of the NODE_ENV this way:在脚本中,我以这种方式记录 NODE_ENV 的值:
console.log(process.env.NODE_ENV)
My system variable:我的系统变量:
d:\>echo %NODE_ENV%
development
My NPN content:我的 NPN 内容:
...
"private": true,
"main": "start.js",
"scripts": {
"start": "node --use_strict start.js",
...
The problem:问题:
node --use_strict start.js
- returns: "development" (right)当我运行node --use_strict start.js
- 返回:“development”(右)npm start
- returns production (wrong)当我运行npm start
- 返回生产(错误)(win: 7, npm: 3.8.3, node: v5.10.1) (赢:7,npm:3.8.3,节点:v5.10.1)
The solution:解决方案:
npm config set production=false
The NPM provides own config register. NPM 提供了自己的配置寄存器。
Hre is an info: https://docs.npmjs.com/cli/config这是一个信息: https ://docs.npmjs.com/cli/config
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.