</>PackageGraphPackageGraph

getopts

npmv2.3.0TypeScript

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

0
Direct dependencies

Runtime packages this one declares itself.

0
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

18 KB
Install size

Unpacked size of this package plus its entire runtime tree.

Tree depth

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.

PackageWeekly downloadsDependentsLicenseLast release
getoptsthis page4.2M1MIT5 years ago
has-flag166.9M1MIT1 day ago
meow36.7M1MIT1 day ago
commander451.1M11MIT1 day ago
yn30.3M1MIT1 day ago
optionator02MIT1 day ago

Dependencies

Declared by getopts v2.3.0. Runtime dependencies are installed with the package; dev dependencies are not.

Dev (2)

c8 *twist *

Used by

Popular packages that depend on getopts.

Relationship graph

Dependencies (left) and dependents (right) of getopts.

knexgetopts
getopts dependencies dependents

Frequently installed together

Release history

No releases in the last two years, typically about 15 days apart.

Recent versions of getopts
VersionPublishedSizeLicense
2.3.0latest5 years ago18 KBMIT
2.2.57 years ago16 KBMIT
2.2.47 years ago15 KBMIT
2.2.37 years ago15 KBMIT
2.2.28 years ago14 KBMIT
2.2.18 years ago14 KBMIT
2.2.08 years ago14 KBMIT
2.1.28 years ago8.5 KBMIT
2.1.18 years ago8.5 KBMIT
2.1.08 years ago8.9 KBMIT
2.0.68 years ago7.9 KBMIT
2.0.58 years ago7.9 KBMIT
2.0.48 years ago7.9 KBMIT
2.0.38 years ago7.9 KBMIT
2.0.28 years ago7.9 KBMIT

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

Keywords

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.