NODE_ENV = NODE_ENV = NODE_ENV = NODE_ENV = NODE_ENV = NODE_ENV = NODE_ENV The code shown in the document is as follows:

// code in app.js file
console.log('NODE_ENV has the value: '+process.env.NODE_ENV) 
Copy the code
// Terminal command line
NODE_ENV=production node app.js
Copy the code

Run it…Emm, what the hell is going on? Was there a mistake in the official documentation? After a search, it was found that the command line for setting running variables is different in different operating systems. Windows should be like this:

set NODE_ENV=production &&  node app.js
Copy the code

All right, change position and try again… At this point, some people may have run successfully, some people may encounter the following error.This is because the terminal is Powershell, which does not support the “&&” symbol, the solution is simple, powershell to CMD. The switching mode is as follows: The final successful run looks like this:

Thanks for browsing!