Node.js

Yarn CLI

Yarn package manager commands for JavaScript projects.

26 commands
Windows MacOS Linux
#javascript #package-manager

Package Management

Initialize a new package.json
yarn init
Add a package as dependency
yarn add react
Add a package as dev dependency
yarn add -D typescript
Remove a package
yarn remove lodash
Install all dependencies
yarn install
Upgrade a specific package
yarn upgrade react
Install a package globally
yarn global add create-react-app

Scripts

Run a script defined in package.json
yarn run build
Run the start script
yarn start
Run the test script
yarn test
Run the lint script
yarn run lint

Workspace

Show workspace dependency tree
yarn workspaces info
Add dependency to specific workspace
yarn workspace my-app add react
Run script in all workspaces
yarn workspaces run build
Remove dependency from workspace
yarn workspace my-app remove lodash

Cache

List cached packages
yarn cache list
Print cache directory path
yarn cache dir
Clear the global cache
yarn cache clean

Info & Config

Show info about a package
yarn info react
List installed packages at top level
yarn list --depth=0
Set a config value
yarn config set registry https://r.co
Show why a package is installed
yarn why react-dom
List licenses of installed packages
yarn licenses list

Quick Commands

Add a package as a project dependency
yarn add <package>
Install all dependencies from package.json
yarn install
Remove a package from the project
yarn remove <package>