getopts
npmv2.3.0TypeScriptParse CLI arguments.
Not recommended for new projects
No — getopts should not be adopted for new projects. Last published 2032 days ago.
- AAdoption: grade A, Excellent.
4.2M downloads per week and 1 known dependents.
- FMaintenance: grade F, Failing.
Last published 2032 days ago.
- AWeight: grade A, Excellent.
Zero runtime dependencies, about 18 KB installed.
- BSupply chain: grade B, Good.
This package has a single maintainer (bus factor of 1).
- ALicense: grade A, Excellent.
MIT — permissive, with no copyleft found in the dependency tree.
Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.
Install cost
What you actually take on by adding getopts to a project.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
Longest resolved dependency chain below this package.
Compatibility
- Node.js
- No constraint declared
- Module format
- ESM + CommonJS
- TypeScript
- Types included
- Install scripts
- None
Quick start
A usage example from the getopts README.
import getopts from "getopts"
const options = getopts(process.argv.slice(2), {
alias: {
output: ["o", "f"],
type: "t",
},
})getopts vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| getoptsthis page | 4.2M | 1 | MIT | 5 years ago |
| has-flag | 166.9M | 1 | MIT | 1 day ago |
| meow | 36.7M | 1 | MIT | 1 day ago |
| commander | 451.1M | 11 | MIT | 1 day ago |
| yn | 30.3M | 1 | MIT | 1 day ago |
| optionator | 0 | 2 | MIT | 1 day ago |
Dependencies
Declared by getopts v2.3.0. Runtime dependencies are installed with the package; dev dependencies are not.
Dev (2)
Used by
Popular packages that depend on getopts.
Relationship graph
Dependencies (left) and dependents (right) of getopts.
Frequently installed together
the complete solution for node.js command-line programs
Lodash modular utilities.
An AST-based pattern checker for JavaScript.
A tiny (183B to 210B) and fast utility to ascend parent directories
Prettier is an opinionated code formatter
[](https://github.com/mmkal/expect-type/actions/workflows/ci.yml)  [](ht
PostgreSQL client - pure javascript & libpq with the same API
TypeScript execution environment and REPL for node.js, with source map support
Functions for dealing with a PostgreSQL connection string
fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS
Tomorrow's ECMAScript modules today!
The fastest and simplest library for SQLite in Node.js.
Release history
No releases in the last two years, typically about 15 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 2.3.0latest | 5 years ago | 18 KB | MIT |
| 2.2.5 | 7 years ago | 16 KB | MIT |
| 2.2.4 | 7 years ago | 15 KB | MIT |
| 2.2.3 | 7 years ago | 15 KB | MIT |
| 2.2.2 | 8 years ago | 14 KB | MIT |
| 2.2.1 | 8 years ago | 14 KB | MIT |
| 2.2.0 | 8 years ago | 14 KB | MIT |
| 2.1.2 | 8 years ago | 8.5 KB | MIT |
| 2.1.1 | 8 years ago | 8.5 KB | MIT |
| 2.1.0 | 8 years ago | 8.9 KB | MIT |
| 2.0.6 | 8 years ago | 7.9 KB | MIT |
| 2.0.5 | 8 years ago | 7.9 KB | MIT |
| 2.0.4 | 8 years ago | 7.9 KB | MIT |
| 2.0.3 | 8 years ago | 7.9 KB | MIT |
| 2.0.2 | 8 years ago | 7.9 KB | MIT |
Overview
getopts is an npm package that parse CLI arguments. It is very popular, with about 4.2M downloads per week and 1 known dependents in the graph. The latest version is 2.3.0, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need parse CLI arguments and value a battle-tested, widely-adopted solution.
When not to use it
Consider an alternative if you need to or if a more actively-maintained option better fits your npm stack.
Pros
- Large, well-established user base (4.2M weekly downloads).
- Ships TypeScript type definitions.
- Clear open-source license (MIT).
- Lean dependency tree (2 direct dependencies).
Cons
- No significant drawbacks detected from available metadata.
Auto-generated from collected registry metadata. No external claims are inferred.
Maintainers
Frequently asked questions
Should I use getopts?
No — getopts should not be adopted for new projects. Last published 2032 days ago.
How do I install getopts?
Run `npm install getopts` to add getopts to your npm project.
What license is getopts released under?
getopts is distributed under the MIT license.
How popular is getopts?
getopts has approximately 4,172,938 downloads per week and 1 known dependent packages.
Is getopts still maintained?
The most recent release of getopts (v2.3.0) was published 5 years ago.
Does getopts run install scripts?
No. getopts does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.