Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

yargs

Options, help and errors for command-line tools.

Dev workflow and configNPM

GitHubWebsite

1. License

“Permission is hereby granted, free of charge, to any person obtaining a copy”

Paid and closed-source products may use it; no fee and no on-screen credit needed.

github.com/yargs/yargs/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What yargs does

yargs is a free JavaScript package for Node.js that reads the words typed after a command, such as --port 8080. You list your options once; yargs turns what the person typed into named values, prints a help screen and reports typos. It can also read chat-bot commands, not only terminal input.

What people build with it

Flags for your project scripts

The build, import or seed script your AI assistant writes gets --port, --open or --dry-run flags with defaults, so you change behaviour without editing code.

Slash commands in a chat bot

Your Slack or Discord bot reads messages like "resize cat.jpg -w 640" and answers with the help text or a clear error when the message is wrong.

Catch typos in options

A mistyped option such as --widht stops the tool with a clear message instead of being quietly ignored.

Check values before the work starts

Stop the tool early when a value makes no sense, such as a port that is not a number, with your own message.

Settings from environment variables

On a server, the same options can come from settings such as MY_PROGRAM_FRUIT_THING instead of typed flags.

Tab completion in the terminal

People who use your tool press Tab to finish command and option names in bash, zsh or fish.

yargs popularity

71 / 100
Gid Score, #329 overall
393M
downloads a week, npm
11.5K
GitHub stars
32
agent projects use it
yargs: downloads per weeknpm, yargs 393,206,605
yargs: GitHub starsyargs/yargs 11,508

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How yargs is used

  • yargs is a dependency in 32 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.7% of the 4,867 JavaScript/TypeScript ones), #41 of 299 in dev workflow and config.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 98; those are left out of every share on this page.
  • The most used alternative in our scan is Commander (174 projects).
  • Projects that use it most often also use tsx (50.0%), chalk (31.2%), TypeScript (81.2%).

By coding agent

18 projects, 0.7%
18 projects, 0.5%
13 projects, 0.4%

Often used with

In 50.0% of its projects
In 31.2% of its projects
In 81.2% of its projects
In 62.5% of its projects
In 40.6% of its projects
In 46.9% of its projects
In 25.0% of its projects
In 25.0% of its projects

More about yargs

Funding
  • GitHub Sponsors: https://github.com/shadowspawn
  • thanks.dev: https://thanks.dev/u/gh/shadowspawn
  • Tidelift: https://tidelift.com/funding/github/npm/yargs
  • 4 GitHub sponsors

See all

More in Dev workflow and config

Alternatives

yargs This page

MITGid 71393M/wk

Commander

Pick Commander when you prefer its style of declaring commands and options; it is another complete toolkit for Node.js command-line programs.

MITGid 82788M/wk

Click

Pick Click when your tool is written in Python rather than JavaScript.

Compare yargs with another tool

Get started

Tell your AI assistant

“Use the npm package yargs (pin yargs@18.2.0, Node.js 20.19+ or 22.12+, ES modules) to give this script --port and --dry-run options with defaults, a --help screen and .strict() so mistyped options fail.”

  1. Add yargs to your Node.js project (Node.js 20.19+, 22.12+ or 23+ for version 18).

    npm i yargs

    From github.com/yargs/yargs/blob/main/README.md

  2. Parse what was typed after the script name; hideBin drops the first two entries of process.argv for you.

    import yargs from 'yargs';
    import {hideBin} from 'yargs/helpers';
    const argv = yargs(hideBin(process.argv)).parse();
    

    From github.com/yargs/yargs/blob/main/README.md

Mistakes to avoid

const argv = require('yargs').argv (yargs 17 and older examples)
import yargs from 'yargs'; import {hideBin} from 'yargs/helpers'; const argv = yargs(hideBin(process.argv)).parse()

yargs 18 is ES modules first and removed the global yargs.argv shortcut.

Installing yargs 18 on Node.js 18 or 20.0-20.18
Use Node.js 20.19+ or 22.12+, or stay on yargs 17.7.x for older Node.js

Version 18 raised the minimum Node.js versions.

Leaving out .strict(), so --widht 640 is quietly accepted
Add .strict() (or .strictOptions()) so unknown options are reported as errors

Without it, a mistyped option just becomes an extra value; in our run .strict() turned it into "Unknown argument widht".

Trusting type: 'number' to reject text such as --port eighty
Add .check(argv => Number.isInteger(argv.port) || 'port must be a whole number')

In our run --port eighty gave NaN with no error; only the .check() rule stopped it.

import Yargs from 'https://unpkg.com/yargs@…/browser.mjs' in a production web page
Bundle yargs/browser with your build tool, or map the two unpkg.com addresses it imports to local copies

The browser entry imports cliui and yargs-parser straight from unpkg.com at run time.

Questions

Can I still use require('yargs') and yargs.argv from old examples?

Not as before. Version 18 is ES modules first and removed the yargs.argv shortcut; use import and yargs(hideBin(process.argv)).parse().

Does it work outside the terminal?

Yes. Pass the text to parse() with a callback and yargs returns the values and any help or error text instead of printing it, which suits chat bots.

Does it come with TypeScript types?

The types live in the separate @types/yargs package.

Which value wins if a setting comes from both a flag and an environment variable?

The typed flag wins, then the environment variable, then a config file, then the default.

Can I use it in a paid product?

Yes. It is MIT licensed; keep the license notice with its files.