does process.env.NODE_ENV sets to 'production' automatically? does process.env.NODE_ENV sets to 'production' automatically? heroku heroku

does process.env.NODE_ENV sets to 'production' automatically?


process.env refers to the environment variables on the system. This depends a whole lot on where the application runs and how the system is configured. Herocku does not know if a specific version of your app is in test or production. So the developer has defined an environment and added 'production' as a variable in that environment.

If you use npm you can add variables with script command

{  ..  "scripts": {    "dev": "corss-env ENVIRONMENT=development ..",    "prod": "cross-env ENVIRONMENT=production .."  }  ..}

and use the appropriate command as run according to setting.

https://www.npmjs.com/package/cross-env


Inside in your project in Heroku, you can set all environments variables.Go in your project > settings > Config Vars and set NODE_ENV production.