Skip to content

Instantly share code, notes, and snippets.

@gregberge
Created July 10, 2013 22:53
Show Gist options
  • Save gregberge/5970919 to your computer and use it in GitHub Desktop.
Save gregberge/5970919 to your computer and use it in GitHub Desktop.
Simple configuration module using nconf.
var nconf = require('nconf');
module.exports = nconf
.env()
.file(__dirname + '/config.json')
.file('env', __dirname + '/config.' + nconf.get('NODE_ENV') + '.json')
.file('user', __dirname + '/config.' + nconf.get('NODE_ENV') + '.' + nconf.get('USER') + '.json');
@naholyr
Copy link

naholyr commented Jul 13, 2013

Beware line 6: naming it "env" overrides previous ".env()" and last one will try to load "config.undefined.undefined.json" ;)

@naholyr
Copy link

naholyr commented Jul 13, 2013

Nope, in fact it doesn't work, it was working only because of the name "env", we have to dig deeper…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment