Github url


by yargs

yargs /yargs

yargs the modern, pirate-themed successor to optimist.

8.0K Stars 770 Forks Last release: about 1 month ago (v15.4.1) MIT License 1.6K Commits 165 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


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

Build Status NPM version js-standard-style Coverage Conventional Commits Slack

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.

  • bash-completion shortcuts for commands and options.
  • and tons more.


Stable version:

npm i yargs

Bleeding edge version with the most recent features:

npm i [email protected]

Usage :

Simple Example

#!/usr/bin/env node
const {argv} = require('yargs')

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!

Complex Example

#!/usr/bin/env node
require('yargs') // eslint-disable-line
  .command('serve [port]', 'start the server', (yargs) => {
      .positional('port', {
        describe: 'port to bind on',
        default: 5000
  }, (argv) => {
    if (argv.verbose)`start server on :${argv.port}`)
  .option('verbose', {
    alias: 'v',
    type: 'boolean',
    description: 'Run with verbose logging'

Run the example above with

to see the help for the application.


yargs has type definitions at @types/yargs.

npm i @types/yargs --save-dev

See usage examples in docs.


See usage examples of yargs with webpack in docs.

Community :

Having problems? want to contribute? join our community slack.

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.