yargs breaking changes

npm

68 curated breaking changes across major versions of yargs. Use this as a migration checklist before bumping dependencies.

68
changes
Breaking changes by transition
  • 8.0.2 \u2192 9.0.0behavior

    parse() now behaves as an alias for .argv, unless a parseCallback is provided.

  • 8.0.2 \u2192 9.0.0behavior

    version() and help() are now enabled by default, and show up in help output; the implicit help command can no longer be enabled/disabled independently from the help command itself (which can now be disabled).

  • 7.1.0 \u2192 8.0.0api

    the first argument to strict() is now used to enable/disable its functionality, rather than controlling whether or not it is global.

  • 7.1.0 \u2192 8.0.0breaking

    extends functionality now always loads the JSON provided, rather than reading from a specific key

  • 7.1.0 \u2192 8.0.0breaking

    Node 4+ is now required; this will allow us to start updating our dependencies.

  • 6.6.0 \u2192 7.0.0api

    the arguments passed to functions are now validated, there's a good chance this will throw exceptions for a few folks who are using the API in an unexpected way.

  • 6.6.0 \u2192 7.0.0behavior

    by default options, and many of yargs' parsing helpers will now default to being applied globally; such that they are no-longer reset before being passed into commands.

  • 6.6.0 \u2192 7.0.0behavior

    context now takes precedence over argv and defaults

  • 6.6.0 \u2192 7.0.0breaking

    `extends` key in config file is now used for extending other config files

  • 6.6.0 \u2192 7.0.0breaking

    yargs will no longer aggressively suppress errors, allowing errors that are not generated internally to bubble.

  • 6.6.0 \u2192 7.0.0breaking

    environment variables now take precedence over config files.

  • 5.0.0 \u2192 6.0.0breaking

    coerce is now applied as a final step after other parsing is complete

  • 4.8.1 \u2192 5.0.0behavior

    we now default to an empty builder function when command is executed with no builder.

  • 4.8.1 \u2192 5.0.0behavior

    introduces a default `help` command which outputs help, as an alternative to a help flag.

  • 4.8.1 \u2192 5.0.0breaking

    fail is now applied globally.

  • 4.8.1 \u2192 5.0.0breaking

    yargs-parser now better handles negative integer values, at the cost of handling numeric option names, e.g., -1 hello

  • 4.8.1 \u2192 5.0.0breaking

    interpret demand() numbers as relative to executing command ([#582](https://github.com/yargs/yargs/issues/582)) ([927810c](https://github.com/yargs/yargs/commit/927810c))

  • 4.8.1 \u2192 5.0.0removed

    default: removed undocumented `defaults` alias for `default`.

  • 3.32.0 \u2192 4.0.0api

    [#330](https://github.com/bcoe/yargs/pull/330) **breaking change**, fix inconsistencies with `.version()` API. (@maxrimue).

  • 3.32.0 \u2192 4.0.0api

    [#368](https://github.com/bcoe/yargs/pull/368) **breaking change**, overhaul to command handling API:

  • 3.32.0 \u2192 4.0.0api

    [#376](https://github.com/bcoe/yargs/pull/376) **breaking change**, make help() method signature

  • 3.32.0 \u2192 4.0.0api

    [#382](https://github.com/bcoe/yargs/pull/382) pass error as extra parameter to fail (@gajus)

  • 3.32.0 \u2192 4.0.0breaking

    [#384](https://github.com/bcoe/yargs/pull/384) add new number type to yargs (@lrlna, @maxrimue)

  • 3.32.0 \u2192 4.0.0breaking

    [#378](https://github.com/bcoe/yargs/pull/378) introduces the pkgConf feature, which tells

  • 3.32.0 \u2192 4.0.0breaking

    [#364](https://github.com/bcoe/yargs/pull/364) add the slick new yargs website to the package.json (@iarna).

  • 3.32.0 \u2192 4.0.0breaking

    [#357](https://github.com/bcoe/yargs/pull/357) .strict() now requires that a valid command is provided (@lrlna)

  • 3.32.0 \u2192 4.0.0breaking

    [#356](https://github.com/bcoe/yargs/pull/356) pull the parsing bits of yargs into the separate module yargs-parser. Various parsing options can now be turned on and off using configuration (@bcoe).

  • 17.7.2 \u2192 18.0.0breaking

    minimum node.js versions now `^20.19.0 || ^22.12.0 || >=23`.

  • 17.7.2 \u2192 18.0.0breaking

    yargs is now ESM first

  • 17.7.2 \u2192 18.0.0breaking

    command names are not derived from modules passed to `command`.

  • 17.7.2 \u2192 18.0.0removed

    singleton usage of yargs yargs.foo, yargs().argv, has been removed.

  • 16.2.0 \u2192 17.0.0api

    #1823 contains the following breaking API changes:

  • 16.2.0 \u2192 17.0.0breaking

    .positional() now allowed at root level of yargs.

  • 16.2.0 \u2192 17.0.0breaking

    **node:** drop Node 10 (#1919)

  • 16.2.0 \u2192 17.0.0breaking

    implicitly private methods are now actually private

  • 16.2.0 \u2192 17.0.0breaking

    **yargs-factory:** refactor yargs-factory to use class (#1895)

  • 16.2.0 \u2192 17.0.0breaking

    **coerce:** coerce is now applied before validation.

  • 16.2.0 \u2192 17.0.0breaking

    **async:** yargs now returns a promise if async or check are asynchronous.

  • 16.2.0 \u2192 17.0.0breaking

    **middleware:** global middleware now applied when no command is configured.

  • 16.2.0 \u2192 17.0.0breaking

    now returns a promise if handler is async.

  • 16.2.0 \u2192 17.0.0breaking

    getCompletion now invokes callback with err and `completions, returns promise of completions.

  • 16.2.0 \u2192 17.0.0deprecated

    deprecated reset() method is now private (call yargs() instead).

  • 16.2.0 \u2192 17.0.0removed

    onFinishCommand removed, in favor of being able to await promise.

  • 15.4.0 \u2192 16.0.0api

    tweaks to ESM/Deno API surface: now exports yargs function by default; getProcessArgvWithoutBin becomes hideBin; types now exported for Deno.

  • 15.4.0 \u2192 16.0.0breaking

    rebase helper is no longer provided on yargs instance.

  • 15.4.0 \u2192 16.0.0breaking

    find-up replaced with escalade; export map added (limits importable files in Node >= 12); [email protected] (new decamelize/camelcase implementation).

  • 15.4.0 \u2192 16.0.0breaking

    **usage:** single character aliases are now shown first in help output

  • 15.4.0 \u2192 16.0.0breaking

    drop support for EOL Node 8 (#1686)

  • 15.1.0 \u2192 15.2.0breaking

    **deps:** [email protected] no longer implicitly creates arrays out of boolean

  • 14.2.0 \u2192 15.0.0breaking

    **deps:** yargs-parser now throws on invalid combinations of config (#1470)

  • 14.2.0 \u2192 15.0.0breaking

    [email protected] drops support for Node 6

  • 14.2.0 \u2192 15.0.0breaking

    drop Node 6 support (#1461)

  • 14.2.0 \u2192 15.0.0removed

    remove package.json-based parserConfiguration (#1460)

  • 13.3.0 \u2192 14.0.0api

    we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed

  • 13.3.0 \u2192 14.0.0breaking

    previously to this fix methods like `yargs.getOptions()` contained the state of the last command to execute.

  • 13.3.0 \u2192 14.0.0breaking

    do not allow additional positionals in strict mode

  • 12.0.5 \u2192 13.0.0breaking

    options with leading '+' or '0' now parse as strings

  • 12.0.5 \u2192 13.0.0breaking

    dropping Node 6 which hits end of life in April 2019

  • 12.0.5 \u2192 13.0.0breaking

    see [[email protected] CHANGELOG](https://github.com/yargs/yargs-parser/blob/main/CHANGELOG.md#breaking-changes)

  • 12.0.5 \u2192 13.0.0breaking

    we now warn if the yargs stanza package.json is used.

  • 11.1.0 \u2192 12.0.0api

    Options absent from `argv` (not set via CLI argument) are now absent from the parsed result object rather than being set with `undefined`

  • 11.1.0 \u2192 12.0.0breaking

    yargs-parser does not populate 'false' when boolean flag is not passed

  • 11.1.0 \u2192 12.0.0breaking

    drop Node 4 from testing matrix, such that we'll gradually start drifting away from supporting Node 4.

  • 11.1.0 \u2192 12.0.0breaking

    tests that assert against help output will need to be updated

  • 10.1.2 \u2192 11.0.0breaking

    requiresArg now has significantly different error output, matching nargs.

  • 9.1.0 \u2192 10.0.0api

    .usage() no longer accepts an options object as the second argument. It can instead be used as an alias for configuring a default command.

  • 9.1.0 \u2192 10.0.0breaking

    previously hidden options were simply implied using a falsy description

  • 9.1.0 \u2192 10.0.0breaking

    help command now only executes if it's the last positional in argv._

API access

Get this data programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/breaking/npm/yargs
yargs breaking changes — npm migration guide | DepScope