pgee70
pgee70

Reputation: 4014

process.env.NODE_ENV is undefined in one project, but not another

I am using the react boilerplate framework to develop two projects. Both projects use cross-env to inject a value into the process.env.NODE_ENV. my webpack package.json is identical in both projects, and an excerpt is:

"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.

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.

Aside from not setting the process.env.NODE_ENV, the rest of the app works fine.

I have tried removing the node_modules folder and package-lock.json and done an 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?

Upvotes: 1

Views: 816

Answers (1)

pgee70
pgee70

Reputation: 4014

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.

Upvotes: 0

Related Questions