Cheat Sheets

Yarn

Created: 2017 May 19th

Updated: 2021 January 4th

Yarn global binaries not showing

When you globally add a package with yarn and it doesn’t show in the terminal.

Usually adding the path to your .bashrc or .zshrc works, try adding this:

GNU Bash icon
# nano ~/.bashrc
# or
# nano ~/.zshrc
export PATH="$PATH:$(yarn global bin)"

If that doesn’t work you may need to set the yarn prefix.

Steps

Confirm your global bin path:

GNU Bash icon
yarn global bin

I got: /home/username/.yarn/bin

set yarn prefix:

make sure your yarn prefix is the parent directory of your bin directory. You can confirm by running

GNU Bash icon
yarn config get prefix

When I ran this it was undefined, so I set it:

GNU Bash icon
yarn config set prefix ~/.yarn

Add the following to ~/.zshrc or ~/.bashrc

GNU Bash icon
export PATH="$PATH:`yarn global bin`"

Source

Update dependencies

Update all project dependencies to lates versions.

GNU Bash icon
yarn upgrade --latest

Globally add a package

GNU Bash icon
yarn global add netlify-cli

Upgrade global packages

GNU Bash icon
yarn global upgrade

displays the location of the yarn bin folder.

GNU Bash icon
yarn bin

list installed packages.

GNU Bash icon
yarn ls

create-react-app

Couple of good one here from @beedesignllc

GNU Bash icon
yarn create react-app my-app-name

☝️ downloads and runs latest create-react-app works for other similarly named pkgs

flow

GNU Bash icon
yarn flow

☝️ will run node_modules/.bin/flow without you having to add it as a package.json script.

npm ci

The equivalent to npm ci for yarn:

GNU Bash icon
yarn install --frozen-lockfile