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

Using defaults, env or argv causes save to fail #43

Closed
calmh opened this issue Jun 9, 2012 · 1 comment
Closed

Using defaults, env or argv causes save to fail #43

calmh opened this issue Jun 9, 2012 · 1 comment

Comments

@calmh
Copy link

calmh commented Jun 9, 2012

Having a .defaults call in the chain causes save to fail with an exception as below. The same happens with either .env or .argv present. The examples seem to indicate this should be a valid way to use nconf.

jb@jborg-mbp:~/tmp % npm list
/Users/jb/tmp
└─┬ nconf@0.5.1 
  ├── async@0.1.22 
  ├── ini@1.0.2 
  ├─┬ optimist@0.3.4 
  │ └── wordwrap@0.0.2 
  └── pkginfo@0.2.3 

jb@jborg-mbp:~/tmp % cat test.js 
var nconf = require('nconf');
nconf.file({ file: 'settings.json' });
nconf.defaults({
    foo: 'bar'
});
nconf.save();
jb@jborg-mbp:~/tmp % node test.js 

/Users/jb/tmp/node_modules/nconf/lib/nconf/common.js:96
    Object.keys(obj).forEach(function (key) {
           ^
TypeError: Object.keys called on non-object
    at Function.keys (native)
    at /Users/jb/tmp/node_modules/nconf/lib/nconf/common.js:96:12
    at Array.forEach (native)
    at Object.merge (/Users/jb/tmp/node_modules/nconf/lib/nconf/common.js:95:8)
    at [object Object].save (/Users/jb/tmp/node_modules/nconf/lib/nconf/provider.js:425:19)
    at Object.<anonymous> (/Users/jb/tmp/test.js:6:7)
    at Module._compile (module.js:446:26)
    at Object..js (module.js:464:10)
    at Module.load (module.js:353:31)
    at Function._load (module.js:311:12)
@pksunkara
Copy link
Contributor

Duplicate of #36

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

No branches or pull requests

2 participants