finds.dev← search

// the find

tj/commander.js

★ 28,287 · JavaScript · MIT · updated Jun 2026

node.js command-line interfaces made easy

Commander.js is the de facto standard CLI argument parser for Node.js — options, subcommands, validation, and auto-generated help. It has been around since 2011, maintained by the community after TJ handed it off, and is a transitive dependency in half the Node ecosystem.

Zero runtime dependencies and under 10KB installed size, which matters when it's pulled in by 50 other packages. The fluent API is readable and self-documenting — option definitions double as help text, which forces authors to keep them in sync. Option conflict and implication modeling (`--disable-server` conflicts with `--port`, `--free-drink` implies `drink: small`) catches configuration errors at parse time instead of deep in business logic. The `extra-typings` companion package infers TypeScript types from the option declarations, giving you typed `.opts()` without hand-writing interfaces.

Subcommand inheritance is a footgun: `.command()` silently copies settings at creation time, but `.addCommand()` does not — you need `.copyInheritedSettings()` manually. This asymmetry has bitten plenty of people who expected consistent behavior. Optional option-arguments (`--flag [value]`) have inherently ambiguous parsing — the docs acknowledge this and point to a separate in-depth doc, which means you will hit edge cases. Environment variable binding (`Option.env()`) has no type coercion, so you still have to parse the string yourself or use a custom `argParser`. The event-based API (`.on('option:verbose', ...)`) is still there but feels like dead weight next to hooks — two overlapping mechanisms for the same problem.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →