node-config

Node-config custom-environment-variables not Picking Docker environment Variables


Working on Windows OS.

My node app using node-config isn't using docker environment variables. It's always using the default config.

I am using node-config custom environment variables as described here: https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables

Everything is working well when running the app locally. The config by passes the default ones and takes the ones defined in my User variables when set.

Problem

However, the node app still uses the default config, instead of the environment variables.

I am not sure what setup I may be missing.


Solution

  • I'm a maintainer of node-config. I don't test with Docker or Heroku, but this most be an ordering problem. As long as the environment variables are set before require('config') happens, they will work-- at that point Docker or Heroku doesn't matter. The activity is happening inside the Node.js JavaScript engine at that point.

    Try this simple test: Just before your line where you require('config'), use console.log or an equivalent to print out the environment variables that you care about. I expect you'll find that when it's not working it's because the environment variables are not set before node-config is loaded.