YARN Cheatsheet

Manthan Ankolekar - Jul 16 '22 - - Dev Community

Install via npm

npm install --global yarn
Enter fullscreen mode Exit fullscreen mode

Check installation

yarn --version
Enter fullscreen mode Exit fullscreen mode

Starting a new project

yarn init
Enter fullscreen mode Exit fullscreen mode

Adding a dependency

yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
Enter fullscreen mode Exit fullscreen mode

Adding a dependency to different categories of dependencies

Add to devDependenciespeerDependencies, and optionalDependencies respectively:

yarn add [package] --dev
yarn add [package] --peer
yarn add [package] --optional
Enter fullscreen mode Exit fullscreen mode

Upgrading a dependency

yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]
Enter fullscreen mode Exit fullscreen mode

Removing a dependency

yarn remove [package]
Enter fullscreen mode Exit fullscreen mode

Installing all the dependencies of project

yarn

or

yarn install
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .