What You Should Know About NODE_ENV

NODE_ENV is an environment variable popularized by the Express framework. It specifies the environment in which an application is running such as development, staging, production, testing, etc.

By default, our application will run in development environment. And we can change the environment by changing process.env.NODE_ENV. Let’s see how frameworks and libraries will behave in different environments.

Development

Production

Below are common, regardless of frameworks:

express.js

sailsjs

mongoose

There’re more that I don’t list here. As you can see, setting NODE_ENV to production gives the best performance. As this variable is so important and has become globally adopted in Node.js world, you should burn this “always setting NODE_ENV to production” into your mind.

 

 

 

 

Top