1. License
“without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”
MIT allows use in paid and closed-source products.
github.com/tj/commander.js/blob/master/LICENSE3. Used by agents' projects
Dependency in 174 public GitHub projects set up for AI coding agents that we scanned (2.8%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error
What Commander does
Commander is a free JavaScript package for building command-line tools in Node.js. You describe the options your tool takes, and it reads what the person typed, shows a help screen and prints a clear error for wrong input. Your assistant writes less code to turn a script into a proper tool.
What people build with it
Turn a script into a tool with help
Your image script gets named options with defaults, and typing --help shows what each one does, without extra code.
Clear errors for wrong values
When someone types a value your tool does not accept, it stops with a message that lists the allowed values.
One tool with several commands
Like git, your tool has separate commands such as deploy and logs, each with its own options and help page.
Read a setting from the environment
A required port or token can come from a flag or, when the flag is missing, from an environment variable; help names that variable.
Commands that wait for the network
When a command downloads or uploads something, its code can wait for the result before the tool exits.
Test your tool without quitting
Your tests run the tool with sample input many times in one process and check the errors instead of the test run ending.
Commander popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Commander is used
- Commander is a dependency in 174 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.6% of the 4,867 JavaScript/TypeScript ones), #10 of 299 in dev workflow and config.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 558; those are left out of every share on this page.
- Projects that use it most often also use chalk (67.2%), tsx (61.5%), Vitest (63.8%).
- It is more common in projects set up for OpenClaw (13.2%) than for GitHub Copilot (2.1%).
By coding agent
Often used with
More about Commander
Funding
- GitHub Sponsors: https://github.com/shadowspawn
- GitHub Sponsors: https://github.com/abetomo
- Tidelift: https://tidelift.com/funding/github/npm/commander
- 4 GitHub sponsors
More in Dev workflow and config
Alternatives
Commander This page
Pick yargs when you want another widely used Node.js option parser with its own help and command style.
Pick meow for a very small Node.js tool where you write the help text yourself and only need flags parsed.
Pick Click when your command-line tool is written in Python.
Get started
Tell your AI assistant
“Use commander 15.1.0 (pin it; Node.js 22.12+, ESM import) to give my script named options with defaults, allowed values via Option().choices(), a --help screen and a version flag; use parseAsync() if any action is async and exitOverride() in tests.”
Install Commander in a project that runs Node.js 22.12 or newer.
npm install commanderDescribe the options, call parse(), then read the values with opts().
import { program } from 'commander'; program .option('--first') .option('-s, --separator <char>') .argument('<string>'); program.parse(); const options = program.opts(); const limit = options.first ? 1 : undefined; console.log(program.args[0].split(options.separator, limit));For anything bigger than a quick script, or for tests, create your own Command object instead of the shared one.
import { Command } from 'commander'; const program = new Command();
Mistakes to avoid
The default export of a global Command was removed from CommonJS in Commander 12.
Commander 15 removed the old esm.mjs entry.
parse() does not wait for async actions, so errors and the end of the work can be lost.
Without from user, the first two items are treated as the node program and the script name and skipped.
Since Commander 13 extra command-arguments are an error by default.
Questions
Can I use it with require() in a CommonJS project?
Commander 15 is ESM only, but Node.js 22.12+ can load it from CommonJS. If your test runner or bundler cannot, stay on Commander 14 for now.
Does it make the --help screen for me?
Yes. Help is built from the descriptions you give each option and argument; you can also add your own text.
How long are old versions supported?
Older major versions get security updates for 12 months. Version 14 is supported until 2027-05-29.
Can options and arguments be checked automatically?
Yes. Unknown options, missing arguments and extra arguments are reported as errors when the command runs.