Skip to content

[BUG] target.hasOwnProperty is not a function when using toml #911

Description

@Nabrok

Describe the bug

When reading a property of an object from the config with toml a target.hasOwnProperty is not a function error occurs.

config/default.toml:

[foo]
bar = "value"

test.js:

const config = require("config");

console.log(config.has("foo.bar"));
console.log(config.get("foo.bar"));

output:

true
/home/test/node_modules/config/lib/util.js:191
              if (target.hasOwnProperty(property) || (property in target && typeof target[property] !== 'function')) {
                         ^

TypeError: target.hasOwnProperty is not a function
    at Object.get (/home/test/node_modules/config/lib/util.js:191:26)
    at Util.getPath (/home/test/node_modules/config/lib/util.js:606:25)
    at ConfigClass.get (/home/test/node_modules/config/lib/config.js:101:24)
    at Object.<anonymous> (/home/test/test.js:4:20)
    at Module._compile (node:internal/modules/cjs/loader:1761:14)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1481:32)
    at Module._load (node:internal/modules/cjs/loader:1300:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)

Node.js v24.13.0

Expected behavior
The property should be read.

Please tell us about your environment:

  • node-config version: 4.4.1
  • node-version: 24.13.0
  • toml version: 4.1.1

Other information

Works with config v4.3.0 and stops working with v4.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions