Skip to content

config file not being loaded #2040

@fallemand

Description

@fallemand

Hi, I have a simple program:

// my-program.js
#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = yargs(hideBin(process.argv));
argv
  .scriptName("my-program")
  .config()
  .option("test", {
    "demandOption": true
  })
  .parse();

And a config.json file

{
  "test": "teeeest"
}

But when I run

node my-program.js --config ./config.json
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --config   Path to JSON config file
  --test     test message                                           [required]

Missing required argument: test

It's seems it's not getting the test argument from the config.

"yargs": "^17.2.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions