-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nconf.file merges don't work correctly #28
Comments
I remember being burned by this as well. This scenario is not well documented, and perhaps an update should be made since I am not the only one who expected the library to work the way your sample is written. Anyway, the way things currently stand... You can only use each of the convenience (argv, env, file, defaults, overrides) methods once because each uses it's name as the key for the config store. If you want to use multiple files, you need to add them like this: var conf = require('nconf');
conf.add('env-file', {type: 'file', file: path.join(path.resolve(__dirname, '../config'), (conf.get('NODE_ENV') || 'development') + '.json')});
conf.add('default-file', {type: 'file', file: path.resolve(__dirname, '../config/default.json')}); The important part is giving the config store a unique key, which is the first argument passed to add. I'm surprised this issue sat for a month without a response. What's up, @flatiron ? @indexzero ? @mmalecki ? Is this lib being maintained? |
@jstewmon Yes. It is. Unfortunately life can't be all open-source maintenance all the time =D |
@jstewmon A pull-request to fix this issue would make you a hero in my book. |
Fwiw, I solved this problem by deploying my app with npm and using npm's |
@indexzero Watch out - that commit has that |
…an object) Conflicts: lib/nconf/provider.js
Fixed |
…ing instead of an object) Conflicts: lib/nconf/provider.js
2 problems:
nconf.file
defaults operate in the wrong order. You can see in this list below that the chain of overriding goes from top to bottom; the things listed higher up override the ones lower down. Thenconf.file
one operates in the reverse order, however. I had to swap those two lines to get this to work correctly in my app.The text was updated successfully, but these errors were encountered: