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/LICENSE3. Used by agents' projects
Dependency in 32 public GitHub projects set up for AI coding agents that we scanned (0.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
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
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
Often used with
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
More in Dev workflow and config
Alternatives
yargs This page
Pick Commander when you prefer its style of declaring commands and options; it is another complete toolkit for Node.js command-line programs.
Pick Click when your tool is written in Python rather than JavaScript.
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.”
Add yargs to your Node.js project (Node.js 20.19+, 22.12+ or 23+ for version 18).
npm i yargsParse 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();
Mistakes to avoid
yargs 18 is ES modules first and removed the global yargs.argv shortcut.
Version 18 raised the minimum Node.js versions.
Without it, a mistyped option just becomes an extra value; in our run .strict() turned it into "Unknown argument widht".
In our run --port eighty gave NaN with no error; only the .check() rule stopped it.
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.