I'm trying to follow the example here: https://www.npmjs.com/package/nconf
What I'm trying to do is load a configuration json file using nconf, but I can't seem to actually retrieve any of the configs. I've exported this to another file, but I've also tried just running this file directly too. I have:
var config = require('nconf');
//priority order
//1. specific overrides
config.overrides({
'always': 'be this value'
});
//2. process.argv
//3. process.env
config.argv().env();
config.file('development', 'development.json');
console.log(config.get('nodeServer'))
module.exports = config;
Yet the output is always undefined. my json is defined as such:
{
"nodeServer": "http://localhost:8090",
"port": 8090
}
and it's in the same directory as config.js. Any idea why this is occurring?
Also want to note, in my main server.js I have:
var config = require('./config/config');
console.log(config.get('port'));
and that also returns undefined.
Turns out that I just needed this:
config.file('development',
{file: 'config/development.json'});