node.jsconfiguration-managementenvconfig.json

NodeJS config.json vs process.env for configuartion management


I've come across people using both methods to do config management.

What are the pros and cons of each approach?

If I have a lot of variables that I store in my config object, will I have to set them all one by one in an upstart script before executing the node app?


Solution

  • You generally use envvar to keep an application stateless. The same codebase should work in dev, staging, test and production environment. You will put var like MySQL config, API keys, if log is enabled or not, if debug is on or not ...

    Config file are used for variables which are not dependent of the environment. For instance, name of the application, number of items per page ...