Skip to content
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

Loading files in wrong order #109

Closed
emschwartz opened this issue Feb 19, 2014 · 4 comments · Fixed by #117
Closed

Loading files in wrong order #109

emschwartz opened this issue Feb 19, 2014 · 4 comments · Fixed by #117

Comments

@emschwartz
Copy link

When loading multiple config files like this:

nconf
.argv()
.env()
.file({ file: 'config1.json' })
.file({ file: 'config2.json' });

argv and env get loaded properly before the config files but then config2 is overriding config1, even though the documentation suggests that it does the opposite

@carpii
Copy link

carpii commented Mar 2, 2014

Did you solve this issue?

I have a similar problem, but from what I can see when I util.inspect(nconf) it seems nconf cannot use two file stores like this, and the 2nd simply replaces the first entirely.

Ie, its equivalent to just calling

nconf.argv().env().file({ file: 'config2.json' });

@emschwartz
Copy link
Author

I ended up just taking out the second config file and moving those values
into the defaults

On Sun, Mar 2, 2014 at 3:30 PM, carpii notifications@github.com wrote:

Did you solve this issue?

I have a similar problem, but from what I can see nconf cannot use two
file stores like this, and the 2nd simply replaces the first entirely.

Ie, its equivalent to just calling

nconf.argv().env().file({ file: 'config2.json' });

Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-36471754
.

@carpii
Copy link

carpii commented Mar 2, 2014

Ok thankyou, I will use that idea

@vegar
Copy link

vegar commented Mar 13, 2014

Duplicate of #97 and #110.

Loading multiple files without specifying different names for each will overwrite, not merge.

Solution:

nconf
   .argv()
   .env()
   .file('override', 'config1.json')
   .file('defaults', 'config2.json');

MitchellMcKenna added a commit to MitchellMcKenna/nconf that referenced this issue Jun 18, 2014
- Update the Readme with notes that when using multiple config files,
  the user must use a custom key as the first parameter in additional
  nconf.file() calls in order for config heirarchy/inheritance to work
  properly.

Fixes indexzero#97, Fixes indexzero#109, Fixes indexzero#110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants