[英]process.env.NODE_ENV is undefined in one project, but not another
I am using the react boilerplate framework to develop two projects.我正在使用React 样板框架开发两个项目。 Both projects use cross-env to inject a value into the process.env.NODE_ENV.
这两个项目都使用cross-env向 process.env.NODE_ENV 中注入一个值。 my webpack package.json is identical in both projects, and an excerpt is:
我的 webpack package.json 在两个项目中是相同的,摘录如下:
"scripts":{
...
"build": "cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout",
"start": "cross-env NODE_ENV=development node server",
...
}
the issue i have is that the process.env.NODE_ENV is set one project and works as expected, but not the other.我遇到的问题是 process.env.NODE_ENV 被设置为一个项目并按预期工作,但不是另一个。
I have run diffs over much of the code in the two projects and the contents are the same, especially for the code that is from the react boilerplate.我对这两个项目中的大部分代码进行了比较,内容是相同的,尤其是来自 React 样板的代码。
Aside from not setting the process.env.NODE_ENV, the rest of the app works fine.除了不设置 process.env.NODE_ENV,应用程序的 rest 工作正常。
I have tried removing the node_modules folder and package-lock.json and done an npm install
我尝试删除 node_modules 文件夹和 package-lock.json 并完成
npm install
So my question is, how can I work out why the process.env.NODE_ENV is undefined, and how can it be set?所以我的问题是,我如何找出 process.env.NODE_ENV 未定义的原因,以及如何设置它?
for some reason,因为某些原因,
import process from 'process';
had crept into the imports section of my files in the second project.在第二个项目中潜入了我的文件的导入部分。 Sharing this answer in case this happens for someone else.
分享这个答案以防其他人发生这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.