I’m using Windows 10, still and If I:
console.log(NODE_ENV: ${process.env.NODE_ENV}
);
The output is:
NODE_ENV: undefined
after I set NODE_ENV to production on the command line:
set NODE_ENV=production
Is it the server not recognizing the environment variable or the app?
After setting the environment variable with NODE_ENV=production, you need to run your server like so:
export NODE_ENV=production & node index.js
1 Like
Hello,
I had same problem, this solved my issues. I am talking about windows only.
$env:NODE_ENV=“production”
There’s a bug somewhere. I forget where it was reported. Essentially for now us Windows users have to manually edit EnvVars via Control Panel.
And just to make like a little harder there doesn’t seem to be a way to quickly refresh VSCode to pick up the changes to EnVars. So you need to close and re-open VSCode :\