yarn has most of the functionality for the npm CLI. The following table compares the corresponding commands:
| Yarn 0.24.5 | npm CLI 5.0.0 | Description |
| yarn | npm | Alias for yarn install |
| yarn install | npm install | Installs dependencies specified in yarn.lock and package.json |
| yarn add <package> | npm install <package> | Installs the package, adds it to the dependencies list, and generates lock files (prior to 5.0.0, npm CLI required a --save flag) |
| yarn remove <package> | npm uninstall <package> | Uninstalls the package |
| yarn global add <package> | npm install <package> --global | Installs a package globally |
| yarn upgrade | rm -rf node_modules && npm install | Upgrades all packages to the latest version, as allowed by package.json |
| yarn init | npm init | Initializes the development of a package by following a short wizard |
Apart from the basics, yarn also has some non-essential, but otherwise neat, features that'll help you in your workflow:
- yarn licenses ls: Prints out, on the console, a list of packages, their URLs and their licenses
- yarn licenses generate-disclaimer: Generates a text file containing the licenses of all the dependencies
- yarn why: Generates a dependency graph to figure out why a package was downloaded—for example, it might be a dependency of a dependency of our application
- yarn upgrade-interactive: Provides an interactive wizard that allows you to selectively upgrade outdated packages
You can get a full list of CLI commands at https://yarnpkg.com/en/docs/cli/, or by running yarn help on your Terminal.