There is a built-in environment variable called NODE_ENV. You can access it from process.env.NODE_ENV. This variable changes based on what mode you are currently in. When you run npm start, it is equal to ‘development’, when you run npm test it is equal to ‘test’, and when you run npm run build it is equal to ‘production’. This variable is special as it can be used to access different environment configurations based on your mode.
xxxxxxxxxx
"NODE_ENV is an environment variable made popular by the
express web server framework. When a node application is run,
it can check the value of the environment variable and do different
things based on the value.
NODE_ENV specifically is used (by convention) to state whether
a particular environment is a production or a development environment.
A common use-case is running additional debugging or logging code
if running in a development environment."