Policy to Set NODE_ENV Only to production, development, test

Tadashi Shigeoka ·  Thu, May 13, 2021

I’ll introduce the policy of setting NODE_ENV only to production, development, and test.

Nodejs

Background: Want to Organize Values Set for NODE_ENV

I wanted to have a clear principle for NODE_ENV settings without hesitation, so I researched and wrote this article.

Set NODE_ENV Only to production, development, test

For NODE_ENV, I only set the following production, development, and test values:

  • production
  • development
  • test

NODE_ENV=test

I use test because Jest sets NODE_ENV=test by default.

NODE_ENV

Set to ‘test’ if it’s not already set to something else.

Source: Environment Variables · Jest

That’s all from the Gemba about the policy of using only production, development, and test for NODE_ENV in Node.js.