commander breaking changes

npm

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

76
changes
Breaking changes by transition
  • v8.3.0 \u2192 v9.0.0-0breaking

    update package-lock.json to lockfile@2 format (#1659)

  • v8.3.0 \u2192 v9.0.0-0breaking

    `showSuggestionAfterError` is now on by default (#1657)

  • v8.3.0 \u2192 v9.0.0-0breaking

    use command name as prefix for subcommand stand-alone executable name (with fallback to script name for backwards compatibility) (#1571)

  • v8.3.0 \u2192 v9.0.0-0breaking

    *Breaking:* default value specified for boolean option now always used as default value (see .preset() to match some previous behaviours) (#1652)

  • v8.3.0 \u2192 v9.0.0-0breaking

    default value for boolean option only shown in help if true/false (#1652)

  • v9.0.0-1 \u2192 v9.0.0breaking

    update package-lock.json to lockfile@2 format (#1659)

  • v9.0.0-1 \u2192 v9.0.0breaking

    `showSuggestionAfterError` is now on by default (#1657)

  • v9.0.0-1 \u2192 v9.0.0breaking

    *Breaking:* default value specified for boolean option now always used as default value (see .preset() to match some previous behaviours) (#1652)

  • v9.0.0-1 \u2192 v9.0.0breaking

    default value for boolean option only shown in help if true/false (#1652)

  • v9.0.0-1 \u2192 v9.0.0breaking

    use command name as prefix for subcommand stand-alone executable name (with fallback to script name for backwards compatibility) (#1571)

  • v8.0.0-2 \u2192 v8.0.0breaking

    *Breaking:* `CommanderError` code `commander.invalidOptionArgument` renamed `commander.invalidArgument` (#1508)

  • v8.0.0-2 \u2192 v8.0.0breaking

    *Breaking:* TypeScript declaration for `.addTextHelp()` callback no longer allows result of `undefined`, now just `string` (#1516)

  • v8.0.0-2 \u2192 v8.0.0breaking

    refactor `index.tab` into a file per class (#1522)

  • v8.0.0-2 \u2192 v8.0.0breaking

    *Breaking:* Commander 8 requires Node.js 12 or higher (#1500)

  • v8.0.0-2 \u2192 v8.0.0breaking

    remove help suggestion from "unknown command" error message (see `.showHelpAfteError()`) (#1534)

  • v14.0.3 \u2192 v15.0.0-0breaking

    *Breaking:* Commander 15 requires Node.js v22.12.0 or higher (for `require(esm)`).

  • v14.0.3 \u2192 v15.0.0-0breaking

    dev: switch tests from Jest to `node:test` test runner (#2463)

  • v14.0.3 \u2192 v15.0.0-0breaking

    update example to use compatible character for MINGW64 (#2475)

  • v13.1.0 \u2192 v14.0.0breaking

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

  • v12.1.0 \u2192 v13.0.0-0breaking

    TypeScript: include implicit `this` in parameters for action handler callback (#2197)

  • v12.1.0 \u2192 v13.0.0-0breaking

    *Breaking*: throw during Option construction for unsupported option flags, like multiple characters after single `-` (#2270)

  • v13.0.0-0 \u2192 v13.0.0breaking

    *Breaking*: throw on multiple calls to `.parse()` if `storeOptionsAsProperties: true` (#2299)

  • v13.0.0-0 \u2192 v13.0.0breaking

    *Breaking*: throw during Option construction for unsupported option flags, like multiple characters after single `-` (#2270)

  • v13.0.0-0 \u2192 v13.0.0breaking

    TypeScript: include implicit `this` in parameters for action handler callback (#2197)

  • v11.1.0 \u2192 v12.0.0-0breaking

    *Breaking:* throw an error if add a command with name or alias which is already in use (#2059)

  • v11.1.0 \u2192 v12.0.0-0breaking

    *Breaking:* check `passThroughOptions` constraints when using `.addCommand` and throw if parent command does not have `.enablePositionalOptions()` enabled (#1937)

  • v11.1.0 \u2192 v12.0.0-0breaking

    *Breaking:* throw an error if add an option with a flag which is already in use (#2055)

  • v11.1.0 \u2192 v12.0.0-0breaking

    replace non-standard JSDoc of `@api private` with documented `@private` (#1949)

  • v11.1.0 \u2192 v12.0.0-0breaking

    *Breaking:* throw error when calling `.storeOptionsAsProperties()` after setting an option value (#1928)

  • v12.0.0-1 \u2192 v12.0.0breaking

    *Breaking:* throw error when calling `.storeOptionsAsProperties()` after setting an option value (#1928)

  • v12.0.0-1 \u2192 v12.0.0breaking

    *Breaking:* throw an error if add an option with a flag which is already in use (#2055)

  • v12.0.0-1 \u2192 v12.0.0breaking

    *Breaking:* check `passThroughOptions` constraints when using `.addCommand` and throw if parent command does not have `.enablePositionalOptions()` enabled (#1937)

  • v12.0.0-1 \u2192 v12.0.0breaking

    replace non-standard JSDoc of `@api private` with documented `@private` (#1949)

  • v12.0.0-1 \u2192 v12.0.0breaking

    *Breaking:* throw an error if add a command with name or alias which is already in use (#2059)

  • 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

    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.0behavior

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

  • 7.0.0-2 \u2192 7.0.0breaking

    allow hiding options from help

  • 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

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

  • 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

    wrapping bugs in help ([#1365])

  • 7.0.0-2 \u2192 7.0.0deprecated

    document and annotate deprecated routines ([#1349])

  • 7.0.0-2 \u2192 7.0.0removed

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

  • 7.0.0-2 \u2192 7.0.0removed

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

  • 13.1.0 \u2192 14.0.0api

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

  • 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.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

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

  • 13.1.0 \u2192 14.0.0breaking

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

  • 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.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

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

  • 10.0.1 \u2192 11.0.0breaking

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

  • 10.0.1 \u2192 11.0.0breaking

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

  • 9.5.0 \u2192 10.0.0breaking

    wrap command description in help ([#1804])

  • 9.5.0 \u2192 10.0.0breaking

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

API access

Get this data programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/breaking/npm/commander