yargs says nested arguments provided via JSON are "missing"

Using yargs 16.2.0, I’ve defined some nested options and provided them via a config file, but yargs still claims that they are missing:


  .command('do-stuff', 'Does some neat stuff.', o => o
    .option('test.something', {
      type: 'string',
      demandOption: true,
      requiresArg: true,


  "test": {
    "something": "blah"

Executed via …

> node index.js -- do-stuff --env config.json

index.js do-stu

Does some neat stuff.

  --version         Show version number                                [boolean]
  --env             Path to the environment config JSON from which to load
  --help            Show help                                          [boolean]
  --test.something                                           [string] [required]

Missing required argument: test.something

I then edited node_modules/yargs-parser/build/index.cjs (original here) and added a line to log out argv after parsing the config JSON:

setConfigObject(config);            // line 630, existing
console.log(JSON.stringify(argv));  // added for debugging

The resulting output:

    "_": ["do-stuff"],
    "env": "config.json",
        "something": "blah"

I made the same change in node_modules/yargs/build/index.cjs, after line 1472 (just before the "Missing required arguments" message is displayed, and the JSON output still includes the test.something argument.

So, why is yargs claiming that my argument(s) were not supplied, when even argv shows that they were?

6 thoughts on “yargs says nested arguments provided via JSON are "missing"”

Leave a Comment