Yarn is a popular JavaScript package manager used for managing dependencies and packages in web development projects. Here’s a Yarn commands cheat sheet:
Project Initialization
Initialize a New Project:
yarn init
Initialize a New Project with Default Settings:
yarn init -y
Installing Dependencies
Install Dependencies:
yarn add package-name
Install Development Dependencies:
yarn add package-name --dev
Install a Specific Version:
yarn add package-name@version
Updating Dependencies
Update All Dependencies:
yarn upgrade
Update a Specific Package:
yarn upgrade package-name
Removing Dependencies
Remove a Package:
yarn remove package-name
Installing Dependencies from package.json
Install Dependencies Listed in package.json
:
yarn install
Listing Dependencies
List Installed Dependencies:
yarn list
Running Scripts
Run a Script Defined in package.json
:
yarn run script-name
Global Installation
Install a Package Globally:
yarn global add package-name
Run a Globally Installed Package:
yarn global bin
Lock Files
Generate yarn.lock
File:
yarn install --lock-file
Check for Outdated Packages in yarn.lock
:
yarn check --integrity
Miscellaneous
Check Yarn Version:
yarn --version
Show Information about Yarn Installation:
yarn --info
This cheat sheet covers some of the common Yarn commands. Yarn also has many other features and options, so it’s recommended to refer to the official Yarn documentation for more in-depth information.