Yarn Cheat Sheet

Kristian Ranstrom
October 11, 2021
1 min read

Yarn is a cli-based package manager developed by Facebook. You can install it by using npm, which is kind of comical when you think about it:

npm i -g yarn

Here are a bunch of how-to scripts to handle common situations:

INSTALL

Install all items within the package.json or install an individual package into the npm repo.


-- installs anything in the package.json
yarn install

-- installs a new package
yarn add antd
yarn add [email protected]
yarn add antd@latest

-- add to devDependencies
yarn add -D 

-- install from a github repo
yarn add package@github:owner/repo

-- install a global package
yarn global add 

USAGE

Once it's installed, you can run the program by using:

yarn run

You can run a specific command in the package.json file by using:

yarn 
yarn build

OUTDATED

Find packages that are outdated.  This will display a list of available updates with the option of updating.

yarn upgrade-interactive
yarn upgrade-interactive -- latest

LIST PACKAGES

List all of the installed packages…this is the same as just looking in the package.json file

yarn list

 

Other Helpful Commands


-- clear out the cache
yarn cache clean

-- removes unneeded files
yarn autoclean

-- uninstalls a package
yarn remove