Sometimes things vary from environment to environment. Like, how we wear a tie to the office, but would try not to elsewhere, save for a few occasions. Similarly, in Node.js, you might want configuration settings to change in each environment. Some of these settings include IP address, port number, database configurations etc., that change from the development to production environment. The recommended approach for changing your app’s environment is by using the
NODE_ENV environment variable.
Currently, Node.js does not have a standard way of managing config variables, but luckily there are a number of node modules that will help you to standardize this. One among them is the nconf package. Nconf provides a hierarchical Node.js configuration with files, command-line arguments, and environment variables.