0

In our Node.JS application, we have been specifying application environments (dev, qa, stage, prod, etc.) in package.json as below:

"start-prod": "NODE_ENV=prod node ./bin/www",

"start-qa": "NODE_ENV=qa node ./bin/www"

etc.

However, we have realized recently that using NODE_ENV in this manner to specify app environments is not a good practice. So, I am trying to use the npm package node-config for this purpose as well as for loading environment-specific configuration which is currently coming from AWS Parameter Store since there seem multiple advantages of using overriding config files over repeated configuration in AWS Parameter Store.

Therefore, I have created different config.json files, e.g., dev.config.json, qa.config.json, etc. But I am not sure how to specify/read the environment (qa, dev, stage, prod, etc.) and load configuration from the corresponding config.json file.

It may be a very stupid question but I am not able to find a good implementation example for node-config. Any help will be highly appreciated.

Sandeep Parashar
  • 197
  • 1
  • 14

1 Answers1

0

As documented on the node-config wiki, you can create:

default.js
prod.js
dev.js
qa.js
Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49