This article will introduce to you the solution to the nodejs setting NODE_ENV error in the windows environment. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
[Recommended study: "nodejs Tutorial"]
When I was looking at the node document today, I saw "Node.js Chapter "The Difference between Development Environment and Production Environment", I encountered some pitfalls when setting up NODE_ENV. I searched the Internet but couldn't find the answer I wanted, so I posted this post to help everyone avoid the pitfalls. The code shown in the document is as follows:
// app.js 文件中的代码 console.log('NODE_ENV的值为:'+process.env.NODE_ENV)
// 终端命令行 NODE_ENV=production node app.js
Run it...
##emm, what's going on? Is the official document written wrong? I quickly went online to check what was going on. After some inquiries, I found that the command lines for setting running variables are different for different operating systems. It should be like this under Windows:set NODE_ENV=production && node app.js
Programming Video! !
The above is the detailed content of How to solve the error when setting NODE_ENV in nodejs?. For more information, please follow other related articles on the PHP Chinese website!