commander
15.1.0 · 7 Nov 2026MIT785.6M / weekRepositoryHomepagenpmAtom feed
5.1.0 is the newest release of 5.x.
In short
10 breaking11 new2 fixed7 changed1 internal
- Breaking
Support for nested commands with action-handlers (#1 #764 #1149)
- Breaking
Preserve argument order in subcommands (#508 #962 #1138)
- Breaking
Unknown options included in arguments passed to command action handler
- Breaking
Unknown options included in
.args - Breaking
argsin returned result renamedoperandsand does not include anything after first unknown option - Breaking
unknownin returned result has arguments after first unknown option including operands, not just options and values - Breaking
Breaking
.on('command:*', callback)and other command events passed (changed) results from.parseOptions, i.e. operands and unknown - Breaking
Removed EventEmitter from TypeScript definition for Command, eliminating implicit peer dependency on
@types/node
Release note
Added
Support for nested commands with action-handlers (#1 #764 #1149)
.addCommand()for adding a separately configured command (#764 #1149)Allow a non-executable to be set as the default command (#742 #1149)
Implicit help command when there are subcommands (previously only if executables)
Customise implicit help command with
.addHelpCommand()Display error message for unknown subcommand, by default (#432 #1088 #1149)
Display help for missing subcommand, by default (#1088 #1149)
Combined short options as single argument may include boolean flags and value flag and value (e.g.
-a -b -p 80can be written as-abp80).parseOption()includes short flag and long flag expansions.helpInformation()returns help text as a string, previously a private routine.parse()implicitly usesprocess.argvif arguments not specifiedOptionally specify where
.parse()arguments "from", if not following node conventions (#512 #1172)Suggest help option along with unknown command error
TypeScript definition for
commandsproperty ofCommandExport
programpropertycreateCommandfactory method to simplify subclassing
Fixed
Do not emit
command:*for executable subcommands (#809 #1149)Action handler called whether or not there are non-option arguments (#1062 #1149)
Combining option short flag and value in single argument now works for subcommands
Only add implicit help command when it will not conflict with other uses of argument (#1153 #1149)
Implicit help command works with command aliases (#948 #1149)
Options are validated whether or not there is an action handler
Changed
- Breaking
Breaking
.argscontains command arguments with just recognised options removed (#1032 #1138) - Breaking
Breaking display error if required argument for command is missing (#995 #1149)
Tighten TypeScript definition of custom option processing function passed to
.option()- Breaking
Breaking
.allowUnknownOption()(#802 #1138)unknown options included in arguments passed to command action handler
unknown options included in
.args
Only recognised option short flags and long flags are expanded (e.g.
-abor--foo=bar)- Breaking
Breaking
.parseOptions()argsin returned result renamedoperandsand does not include anything after first unknown optionunknownin returned result has arguments after first unknown option including operands, not just options and values
- Breaking
Breaking
.on('command:*', callback)and other command events passed (changed) results from.parseOptions, i.e. operands and unknown Refactor Option from prototype to class
Refactor Command from prototype to class
Changes to error handling
throw for author error, not just display message
preflight for variadic error
add tips to missing subcommand executable
TypeScript fluent return types changed to be more subclass friendly, return
thisrather thanCommand.parseAsyncreturnsPromise<this>to be consistent with.parse()
Removed
- Breaking
Removed EventEmitter from TypeScript definition for Command, eliminating implicit peer dependency on
@types/node - Breaking
Removed private function
normalize(the functionality has been integrated intoparseOptions) - Breaking
parseExpectedArgsis now private
Migration Tips
If you use .on('command:*') or more complicated tests to detect an unrecognised subcommand, you may be able to delete the code and rely on the default behaviour.
If you use program.args or more complicated tests to detect a missing subcommand, you may be able to delete the code and rely on the default behaviour.
If you use .command('*') to add a default command, you may be be able to switch to isDefault:true with a named command.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.