Catalog npm
PACKAGE EXPLORERView in registry

yargs

npm

yargs the modern, pirate-themed, successor to optimist.

argsargumentclicommandoptionparserparsing
Versions collected267
Direct dependencies28From release 18.2.0
Last observed20 Oct, 15:29 UTC

README

Current package documentation

Yargs

Yargs be a node.js library fer hearties tryin' ter parse optstrings


ci NPM version js-standard-style Coverage Conventional Commits

Description

Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.

It gives you:

  • commands and (grouped) options (my-program.js serve --port=5000).
  • a dynamically generated help menu based on your arguments:
mocha [spec..]

Run tests with Mocha

Commands
  mocha inspect [spec..]  Run tests with Mocha                         [default]
  mocha init <path>       create a client-side Mocha setup at <path>

Rules & Behavior
  --allow-uncaught           Allow uncaught errors to propagate        [boolean]
  --async-only, -A           Require all tests to use a callback (async) or
                             return a Promise                          [boolean]
  • generate completion scripts for Bash and Zsh for your command
  • and tons more.

Installation

Stable version:

npm i yargs

Bleeding edge version with the most recent features:

npm i yargs@next

Usage

Simple Example

#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = yargs(hideBin(process.argv)).parse()

if (argv.ships > 3 && argv.distance < 53.5) {
  console.log('Plunder more riffiwobbles!')
} else {
  console.log('Retreat from the xupptumblers!')
}
$ ./plunder.js --ships=4 --distance=22
Plunder more riffiwobbles!

$ ./plunder.js --ships 12 --distance 98.7
Retreat from the xupptumblers!

Note: hideBin is a shorthand for process.argv.slice(2). It has the benefit that it takes into account variations in some environments, e.g., Electron.

Complex Example

#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

yargs(hideBin(process.argv))
  .command('serve [port]', 'start the server', (yargs) => {
    return yargs
      .positional('port', {
        describe: 'port to bind on',
        default: 5000
      })
  }, (argv) => {
    if (argv.verbose) console.info(`start server on :${argv.port}`)
    serve(argv.port)
  })
  .option('verbose', {
    alias: 'v',
    type: 'boolean',
    description: 'Run with verbose logging'
  })
  .parse()

Run the example above with --help to see the help for the application.

Supported Platforms

TypeScript

yargs has type definitions at @types/yargs.

npm i @types/yargs --save-dev

See usage examples in docs.

Deno

As of v16, yargs supports Deno:

import yargs from 'https://deno.land/x/yargs@v17.7.2-deno/deno.ts'
import { Arguments } from 'https://deno.land/x/yargs@v17.7.2-deno/deno-types.ts'

yargs(Deno.args)
  .command('download <files...>', 'download a list of files', (yargs: any) => {
    return yargs.positional('files', {
      describe: 'a list of files to do something with'
    })
  }, (argv: Arguments) => {
    console.info(argv)
  })
  .strictCommands()
  .demandCommand(1)
  .parse()

Note: If you use version tags in url then you also have to add -deno flag on the end, like @17.7.2-deno

Usage in Browser

See examples of using yargs in the browser in docs.

Documentation

Table of Contents

Supported Node.js Versions

Libraries in this ecosystem make a best effort to track Node.js' release schedule. Here's a post on why we think this is important.

Downloads & popularity

0downloads
1-day window · source-reported counts19 Oct 2026
58.4M29.2M0
2026-07-22: 41,933,481 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-22–2026-07-222026-07-23: 40,831,523 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-23–2026-07-232026-07-24: 37,173,970 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-24–2026-07-242026-07-25: 17,532,546 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-25–2026-07-252026-07-26: 17,427,046 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-26–2026-07-262026-07-27: 41,417,853 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-27–2026-07-272026-07-28: 43,675,534 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-28–2026-07-282026-07-29: 42,157,858 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-29–2026-07-292026-07-30: 42,525,707 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-30–2026-07-302026-07-31: 37,631,132 · observed 2026-10-20T09:43:01.3127019Z · period 2026-07-31–2026-07-312026-08-01: 18,743,224 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-01–2026-08-012026-08-02: 18,445,381 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-02–2026-08-022026-08-03: 41,470,571 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-03–2026-08-032026-08-04: 44,204,873 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-04–2026-08-042026-08-05: 44,000,110 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-05–2026-08-052026-08-06: 36,661,308 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-06–2026-08-062026-08-07: 39,909,153 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-07–2026-08-072026-08-08: 18,796,812 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-08–2026-08-082026-08-09: 18,791,735 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-09–2026-08-092026-08-10: 42,376,843 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-10–2026-08-102026-08-11: 43,439,814 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-11–2026-08-112026-08-12: 43,423,936 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-12–2026-08-122026-08-13: 43,478,211 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-13–2026-08-132026-08-14: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-14–2026-08-142026-08-15: 18,774,675 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-15–2026-08-152026-08-16: 18,621,871 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-16–2026-08-162026-08-17: 38,634,638 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-17–2026-08-172026-08-18: 44,582,139 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-18–2026-08-182026-08-19: 43,733,163 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-19–2026-08-192026-08-20: 43,725,097 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-20–2026-08-202026-08-21: 39,365,775 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-21–2026-08-212026-08-22: 19,177,899 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-22–2026-08-222026-08-23: 19,723,105 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-23–2026-08-232026-08-24: 43,662,827 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-24–2026-08-242026-08-25: 46,121,281 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-25–2026-08-252026-08-26: 45,137,002 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-26–2026-08-262026-08-27: 45,404,377 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-27–2026-08-272026-08-28: 39,780,092 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-28–2026-08-282026-08-29: 19,507,430 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-29–2026-08-292026-08-30: 20,038,568 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-30–2026-08-302026-08-31: 43,336,929 · observed 2026-10-20T09:43:01.3127019Z · period 2026-08-31–2026-08-312026-09-01: 48,519,396 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-01–2026-09-012026-09-02: 50,300,256 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-02–2026-09-022026-09-03: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-03–2026-09-032026-09-04: 43,086,299 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-04–2026-09-042026-09-05: 22,045,041 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-05–2026-09-052026-09-06: 21,737,640 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-06–2026-09-062026-09-07: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-07–2026-09-072026-09-08: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-08–2026-09-082026-09-09: 49,705,392 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-09–2026-09-092026-09-10: 49,102,173 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-10–2026-09-102026-09-11: 43,773,549 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-11–2026-09-112026-09-12: 20,989,105 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-12–2026-09-122026-09-13: 21,468,258 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-13–2026-09-132026-09-14: 48,963,554 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-14–2026-09-142026-09-15: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-15–2026-09-152026-09-16: 49,442,932 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-16–2026-09-162026-09-17: 48,948,514 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-17–2026-09-172026-09-18: 44,827,096 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-18–2026-09-182026-09-19: 24,750,892 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-19–2026-09-192026-09-20: 26,743,505 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-20–2026-09-202026-09-21: 49,052,002 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-21–2026-09-212026-09-22: 50,488,006 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-22–2026-09-222026-09-23: 52,204,687 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-23–2026-09-232026-09-24: 51,850,473 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-24–2026-09-242026-09-25: 46,968,371 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-25–2026-09-252026-09-26: 23,261,608 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-26–2026-09-262026-09-27: 23,430,537 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-27–2026-09-272026-09-28: 54,112,753 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-28–2026-09-282026-09-29: 55,682,495 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-29–2026-09-292026-09-30: 56,230,614 · observed 2026-10-20T09:43:01.3127019Z · period 2026-09-30–2026-09-302026-10-01: 56,946,158 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-01–2026-10-012026-10-02: 48,739,120 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-02–2026-10-022026-10-03: 25,556,168 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-03–2026-10-032026-10-04: 25,332,992 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-04–2026-10-042026-10-05: 52,764,300 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-05–2026-10-052026-10-06: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-06–2026-10-062026-10-07: 57,985,421 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-07–2026-10-072026-10-08: 58,396,266 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-08–2026-10-082026-10-09: 51,513,887 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-09–2026-10-092026-10-10: 26,704,362 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-10–2026-10-102026-10-11: 26,931,802 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-11–2026-10-112026-10-12: 51,990,530 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-12–2026-10-122026-10-13: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-13–2026-10-132026-10-14: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-14–2026-10-142026-10-15: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-15–2026-10-152026-10-16: 53,821,177 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-16–2026-10-162026-10-17: 26,818,276 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-17–2026-10-172026-10-18: 27,042,908 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-18–2026-10-182026-10-19: 0 · observed 2026-10-20T09:43:01.3127019Z · period 2026-10-19–2026-10-19
22 Jul19 Oct

npm · 90 observations shown. Missing days are unknown.

View observed values
Date / source periodValueObserved at
2026-10-19 – 2026-10-1902026-10-20T09:43:01.3127019Z
2026-10-18 – 2026-10-1827,042,9082026-10-20T09:43:01.3127019Z
2026-10-17 – 2026-10-1726,818,2762026-10-20T09:43:01.3127019Z
2026-10-16 – 2026-10-1653,821,1772026-10-20T09:43:01.3127019Z
2026-10-15 – 2026-10-1502026-10-20T09:43:01.3127019Z
2026-10-14 – 2026-10-1402026-10-20T09:43:01.3127019Z
2026-10-13 – 2026-10-1302026-10-20T09:43:01.3127019Z
2026-10-12 – 2026-10-1251,990,5302026-10-20T09:43:01.3127019Z
2026-10-11 – 2026-10-1126,931,8022026-10-20T09:43:01.3127019Z
2026-10-10 – 2026-10-1026,704,3622026-10-20T09:43:01.3127019Z
2026-10-09 – 2026-10-0951,513,8872026-10-20T09:43:01.3127019Z
2026-10-08 – 2026-10-0858,396,2662026-10-20T09:43:01.3127019Z
2026-10-07 – 2026-10-0757,985,4212026-10-20T09:43:01.3127019Z
2026-10-06 – 2026-10-0602026-10-20T09:43:01.3127019Z
2026-10-05 – 2026-10-0552,764,3002026-10-20T09:43:01.3127019Z
2026-10-04 – 2026-10-0425,332,9922026-10-20T09:43:01.3127019Z
2026-10-03 – 2026-10-0325,556,1682026-10-20T09:43:01.3127019Z
2026-10-02 – 2026-10-0248,739,1202026-10-20T09:43:01.3127019Z
2026-10-01 – 2026-10-0156,946,1582026-10-20T09:43:01.3127019Z
2026-09-30 – 2026-09-3056,230,6142026-10-20T09:43:01.3127019Z
2026-09-29 – 2026-09-2955,682,4952026-10-20T09:43:01.3127019Z
2026-09-28 – 2026-09-2854,112,7532026-10-20T09:43:01.3127019Z
2026-09-27 – 2026-09-2723,430,5372026-10-20T09:43:01.3127019Z
2026-09-26 – 2026-09-2623,261,6082026-10-20T09:43:01.3127019Z
2026-09-25 – 2026-09-2546,968,3712026-10-20T09:43:01.3127019Z
2026-09-24 – 2026-09-2451,850,4732026-10-20T09:43:01.3127019Z
2026-09-23 – 2026-09-2352,204,6872026-10-20T09:43:01.3127019Z
2026-09-22 – 2026-09-2250,488,0062026-10-20T09:43:01.3127019Z
2026-09-21 – 2026-09-2149,052,0022026-10-20T09:43:01.3127019Z
2026-09-20 – 2026-09-2026,743,5052026-10-20T09:43:01.3127019Z
2026-09-19 – 2026-09-1924,750,8922026-10-20T09:43:01.3127019Z
2026-09-18 – 2026-09-1844,827,0962026-10-20T09:43:01.3127019Z
2026-09-17 – 2026-09-1748,948,5142026-10-20T09:43:01.3127019Z
2026-09-16 – 2026-09-1649,442,9322026-10-20T09:43:01.3127019Z
2026-09-15 – 2026-09-1502026-10-20T09:43:01.3127019Z
2026-09-14 – 2026-09-1448,963,5542026-10-20T09:43:01.3127019Z
2026-09-13 – 2026-09-1321,468,2582026-10-20T09:43:01.3127019Z
2026-09-12 – 2026-09-1220,989,1052026-10-20T09:43:01.3127019Z
2026-09-11 – 2026-09-1143,773,5492026-10-20T09:43:01.3127019Z
2026-09-10 – 2026-09-1049,102,1732026-10-20T09:43:01.3127019Z
2026-09-09 – 2026-09-0949,705,3922026-10-20T09:43:01.3127019Z
2026-09-08 – 2026-09-0802026-10-20T09:43:01.3127019Z
2026-09-07 – 2026-09-0702026-10-20T09:43:01.3127019Z
2026-09-06 – 2026-09-0621,737,6402026-10-20T09:43:01.3127019Z
2026-09-05 – 2026-09-0522,045,0412026-10-20T09:43:01.3127019Z
2026-09-04 – 2026-09-0443,086,2992026-10-20T09:43:01.3127019Z
2026-09-03 – 2026-09-0302026-10-20T09:43:01.3127019Z
2026-09-02 – 2026-09-0250,300,2562026-10-20T09:43:01.3127019Z
2026-09-01 – 2026-09-0148,519,3962026-10-20T09:43:01.3127019Z
2026-08-31 – 2026-08-3143,336,9292026-10-20T09:43:01.3127019Z
2026-08-30 – 2026-08-3020,038,5682026-10-20T09:43:01.3127019Z
2026-08-29 – 2026-08-2919,507,4302026-10-20T09:43:01.3127019Z
2026-08-28 – 2026-08-2839,780,0922026-10-20T09:43:01.3127019Z
2026-08-27 – 2026-08-2745,404,3772026-10-20T09:43:01.3127019Z
2026-08-26 – 2026-08-2645,137,0022026-10-20T09:43:01.3127019Z
2026-08-25 – 2026-08-2546,121,2812026-10-20T09:43:01.3127019Z
2026-08-24 – 2026-08-2443,662,8272026-10-20T09:43:01.3127019Z
2026-08-23 – 2026-08-2319,723,1052026-10-20T09:43:01.3127019Z
2026-08-22 – 2026-08-2219,177,8992026-10-20T09:43:01.3127019Z
2026-08-21 – 2026-08-2139,365,7752026-10-20T09:43:01.3127019Z
2026-08-20 – 2026-08-2043,725,0972026-10-20T09:43:01.3127019Z
2026-08-19 – 2026-08-1943,733,1632026-10-20T09:43:01.3127019Z
2026-08-18 – 2026-08-1844,582,1392026-10-20T09:43:01.3127019Z
2026-08-17 – 2026-08-1738,634,6382026-10-20T09:43:01.3127019Z
2026-08-16 – 2026-08-1618,621,8712026-10-20T09:43:01.3127019Z
2026-08-15 – 2026-08-1518,774,6752026-10-20T09:43:01.3127019Z
2026-08-14 – 2026-08-1402026-10-20T09:43:01.3127019Z
2026-08-13 – 2026-08-1343,478,2112026-10-20T09:43:01.3127019Z
2026-08-12 – 2026-08-1243,423,9362026-10-20T09:43:01.3127019Z
2026-08-11 – 2026-08-1143,439,8142026-10-20T09:43:01.3127019Z
2026-08-10 – 2026-08-1042,376,8432026-10-20T09:43:01.3127019Z
2026-08-09 – 2026-08-0918,791,7352026-10-20T09:43:01.3127019Z
2026-08-08 – 2026-08-0818,796,8122026-10-20T09:43:01.3127019Z
2026-08-07 – 2026-08-0739,909,1532026-10-20T09:43:01.3127019Z
2026-08-06 – 2026-08-0636,661,3082026-10-20T09:43:01.3127019Z
2026-08-05 – 2026-08-0544,000,1102026-10-20T09:43:01.3127019Z
2026-08-04 – 2026-08-0444,204,8732026-10-20T09:43:01.3127019Z
2026-08-03 – 2026-08-0341,470,5712026-10-20T09:43:01.3127019Z
2026-08-02 – 2026-08-0218,445,3812026-10-20T09:43:01.3127019Z
2026-08-01 – 2026-08-0118,743,2242026-10-20T09:43:01.3127019Z
2026-07-31 – 2026-07-3137,631,1322026-10-20T09:43:01.3127019Z
2026-07-30 – 2026-07-3042,525,7072026-10-20T09:43:01.3127019Z
2026-07-29 – 2026-07-2942,157,8582026-10-20T09:43:01.3127019Z
2026-07-28 – 2026-07-2843,675,5342026-10-20T09:43:01.3127019Z
2026-07-27 – 2026-07-2741,417,8532026-10-20T09:43:01.3127019Z
2026-07-26 – 2026-07-2617,427,0462026-10-20T09:43:01.3127019Z
2026-07-25 – 2026-07-2517,532,5462026-10-20T09:43:01.3127019Z
2026-07-24 – 2026-07-2437,173,9702026-10-20T09:43:01.3127019Z
2026-07-23 – 2026-07-2340,831,5232026-10-20T09:43:01.3127019Z
2026-07-22 – 2026-07-2241,933,4812026-10-20T09:43:01.3127019Z

Versions 267

Collected releases
VersionPublishedDirect dependenciesOpen version
18.2.0Registry latest20 Sept 202628
18.1.026 Jul 202628
17.7.319 Jun 202630
16.2.219 Jun 202629
16.2.2-candidate.015 Jun 202629
17.7.3-candidate.012 Jun 202630
18.0.027 May 202528
18.0.0-candidate.725 Apr 202528
18.0.0-candidate.624 Apr 202528
18.0.0-candidate.523 Apr 202528
18.0.0-candidate.416 Apr 202528
18.0.0-candidate.311 Apr 202528
18.0.0-browser.211 Apr 202528
18.0.0-browser.111 Apr 202528
18.0.0-browser.010 Apr 202528
18.0.0-candidate.210 Apr 202528
18.0.0-candidate.19 Apr 202528
17.7.227 Apr 202329
17.7.121 Feb 202329
17.7.016 Feb 202329

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
chevex/yargs

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
yargs/yargs

Shared repository data · GitHub

License detected in repository
Not collected

Repository

PENDING
bcoe/yargs

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 08:15 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:dd2aafee3c42c0caef5faa07a5d881aa1c7be3f8845b91a4ad2c1577142efd13