问题
I am learning NodeJS and I need to know how to set my production environment using process.env.___ .When I run
console.log(app.get('env')); //app is express object 
I get output on command prompt development as environment. But if I try to set an environment variable
eg. process.env.NODE_ENV, on command prompt I write :set NODE_ENV=productionand then again try : console.log(process.env.NODE_ENV); I get output: undefined.
I've been struggling hard and searching online but have't got a solution yet. 
Please, guide me in this matter.
回答1:
I just dug a little and found that in poweshell type $env:NODE_ENV="production". 
It did the work for me. Remember the dollar sign and quotes. 
Here is the source: How can I set NODE_ENV=production on Windows?
来源:https://stackoverflow.com/questions/51945761/can-not-set-environment-variable-in-nodejs-app-windows