I'm trying to put my development project live. So to handle config I'll use nconf.
I have defined on heroku my config var :
NODE_ENV: production
And I have a config object on dev:
config = {
NODE_ENV: development
}
On the app.js file, I require nconf and I configure the priority order to args, env vars, and finally default config object (and it's work):
var nconf = require('nconf');
nconf.argv()
.env()
.defaults(config);
console.log(nconf.get('NODE_ENV')); // development || production
But now I try to use nconf on other file, or lib (required after the previous lines) and it didn't work. I have to copy/past the priority order on each file to configure my default config.
Do I have a solution to define this only one time, and re-use it on each file/lib/controller...
Thank
The process object is a global object and can be accessed from anywhere.