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

Support stores with configurations defined as objects without prototype #314

Open
kosmasgiannis opened this issue Jan 25, 2019 · 1 comment

Comments

@kosmasgiannis
Copy link

If a memory store is added where the configuration is an object without prototype, when you try to get something the following error occurs:

TypeError: target.hasOwnProperty is not a function

Here is an example to reproduce:

var nconf= require('nconf');

var np = Object.assign(Object.create(null), {key1:'value1'});

nconf.add('np', {type: 'literal', store: np});

console.log(nconf.get('key1'));
@ilkkao
Copy link
Contributor

ilkkao commented May 5, 2021

Most importantly ini bump to 2.0.0 includes this change npm/ini@032fbaf

Which in my project with

  nconf.file('defaults', {
    file: path.join(rootPath, 'server', 'mas.conf.default'),
    format: nconf.formats.ini
  });

leads to the same

/Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/stores/memory.js:47
      if (target && target.hasOwnProperty(key)) {
                           ^
  TypeError: target.hasOwnProperty is not a function
     at exports.File.Memory.get (/Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/stores/memory.js:47:26)
     at /Users/ilkkao/git/mas/server/node_modules/nconf/lib/nconf/provider.js:629:32
     at Array.forEach (<anonymous>)

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