commander breaking changes

npm

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

42
changes
Breaking changes by transition
  • 9.0.0-1 \u2192 9.0.0removed

    *Breaking:* removed internal fallback to `require.main.filename` when script not known from arguments passed to `.parse()` (can supply details using `.name()`, and `.executableDir()` or `executableFile`) ([#1571])

  • 8.0.0-2 \u2192 8.0.0behavior

    *Breaking:* TypeScript declaration for default export of global `Command` object ([#1520])

  • 8.0.0-2 \u2192 8.0.0breaking

    (still available as named `program` export)

  • 7.0.0-2 \u2192 7.0.0api

    allow restricting option arguments to a list of choices

  • 7.0.0-2 \u2192 7.0.0api

    `.allowExcessArguments(false)` to show an error message if there are too many command-arguments on command line for the action handler ([#1409])

  • 7.0.0-2 \u2192 7.0.0behavior

    *Breaking:* options are stored safely by default, not as properties on the command ([#1409])

  • 7.0.0-2 \u2192 7.0.0behavior

    revert behaviour with `.storeOptionsAsProperties()`

  • 7.0.0-2 \u2192 7.0.0behavior

    allow setting how default value is shown in help

  • 7.0.0-2 \u2192 7.0.0breaking

    wrapping bugs in help ([#1365])

  • 7.0.0-2 \u2192 7.0.0breaking

    support sorting subcommands and options in help

  • 7.0.0-2 \u2192 7.0.0breaking

    support specifying wrap width (columns)

  • 7.0.0-2 \u2192 7.0.0breaking

    allow subclassing Help class

  • 7.0.0-2 \u2192 7.0.0breaking

    allow configuring Help class without subclassing

  • 7.0.0-2 \u2192 7.0.0breaking

    `.enablePositionalOptions()` to let program and subcommand reuse same option ([#1427])

  • 7.0.0-2 \u2192 7.0.0breaking

    `.passThroughOptions()` to pass options through to other programs without needing `--` ([#1427])

  • 7.0.0-2 \u2192 7.0.0breaking

    `.configureOutput()` to modify use of stdout and stderr or customise display of errors ([#1387])

  • 7.0.0-2 \u2192 7.0.0breaking

    use `.addHelpText()` to add text before or after the built-in help, for just current command or also for all subcommands ([#1296])

  • 7.0.0-2 \u2192 7.0.0breaking

    enhance Option class ([#1331])

  • 7.0.0-2 \u2192 7.0.0breaking

    allow hiding options from help

  • 7.0.0-2 \u2192 7.0.0breaking

    `.createOption()` to support subclassing of automatically created options (like `.createCommand()`) ([#1380])

  • 7.0.0-2 \u2192 7.0.0breaking

    this especially affects accessing options on program, use `program.opts()`

  • 7.0.0-2 \u2192 7.0.0breaking

    *Breaking:* action handlers are passed options and command separately ([#1409])

  • 7.0.0-2 \u2192 7.0.0breaking

    *Breaking:* errors now displayed using `process.stderr.write()` instead of `console.error()`

  • 7.0.0-2 \u2192 7.0.0breaking

    initialise the command description to empty string (previously undefined) ([#1365])

  • 7.0.0-2 \u2192 7.0.0breaking

    refactor the code generating the help into a separate public Help class ([#1365])

  • 7.0.0-2 \u2192 7.0.0deprecated

    document and annotate deprecated routines ([#1349])

  • 7.0.0-2 \u2192 7.0.0removed

    deprecated callback parameter to `.help()` and `.outputHelp()` (removed from README) ([#1296])

  • 7.0.0-2 \u2192 7.0.0removed

    deprecate `.on('--help')` (removed from README) ([#1296])

  • 13.1.0 \u2192 14.0.0api

    support for unescaped negative numbers as option-arguments and command-arguments ([#2339])

  • 13.1.0 \u2192 14.0.0api

    TypeScript: add `parseArg` property to `Argument` class ([#2359])

  • 13.1.0 \u2192 14.0.0breaking

    *Breaking:* Commander 14 requires Node.js v20 or higher

  • 13.1.0 \u2192 14.0.0breaking

    support for groups of options and commands in the help using low-level `.helpGroup()` on `Option` and `Command`, and higher-level `.optionsGroup()` and `.commandsGroup()` which can be used in chaining way to specify group title for following options/commands ([#2328])

  • 13.1.0 \u2192 14.0.0breaking

    `.configureOutput()` now makes copy of settings instead of modifying in-place, fixing side-effects ([#2350])

  • 13.1.0 \u2192 14.0.0breaking

    internal refactor of `Help` class adding `.formatItemList()` and `.groupItems()` methods ([#2328])

  • 13.1.0 \u2192 14.0.0removed

    remove bogus leading space in help when option has default value but not a description ([#2348])

  • 12.0.0-1 \u2192 12.0.0removed

    *Breaking:* removed default export of a global Command instance from CommonJS (use the named `program` export instead) ([#2017])

  • 10.0.1 \u2192 11.0.0api

    leading and trailing spaces are now ignored by the .arguments() method ([#1874])

  • 10.0.1 \u2192 11.0.0breaking

    refine "types" exports for ESM to follow TypeScript guidelines ([#1886])

  • 10.0.1 \u2192 11.0.0breaking

    *Breaking:* Commander 11 requires Node.js v16 or higher

  • 10.0.1 \u2192 11.0.0breaking

    help command works when help option is disabled ([#1864])

  • 9.5.0 \u2192 10.0.0breaking

    *Breaking:* Commander 10 requires Node.js v14 or higher

  • 9.5.0 \u2192 10.0.0breaking

    wrap command description in help ([#1804])

API access

Get this data programmatically \u2014 free, no authentication.

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