DEV Community

Manthan Ankolekar
Manthan Ankolekar

Posted on • Edited on

YARN Cheatsheet

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

Top comments (2)

Collapse
 
troy5890 profile image
Troy Harris

Always heard installing yarn this way wasn't recommended. I need to see if that is accurate or not.

Collapse
 
manthanank profile image
Manthan Ankolekar

Ya, sure if this is good practice of yarn setup, then please share yours if possible. thank you.