Skip to content

Instantly share code, notes, and snippets.

@EngPeterShaker
Created January 20, 2021 15:26
Show Gist options
  • Save EngPeterShaker/1821f0a80ecc98ca0e39248eee1703ab to your computer and use it in GitHub Desktop.
Save EngPeterShaker/1821f0a80ecc98ca0e39248eee1703ab to your computer and use it in GitHub Desktop.
Useful aliases for Yarn

Basic Commands

alias y="yarn"
alias yi="yarn init -y"

Install And Remove Packages

alias ya="yarn add"
alias yr="yarn remove"

Install Packages In Your devDependencies

alias yad="yarn add -D"

Install And Remove Packages Globally

alias yga="yarn global add"
alias ygr="yarn global remove"

Upgrades Packages To Their Latest Version

alias yu="yarn upgrade"
alias ygu="yarn global upgrade"

Clear The Global Cache

alias ycc="yarn cache clean"

Runs A Defined Package Script

alias yrun="yarn run"

List Installed Packages

alias yl="yarn list --depth=0"
alias ygl="yarn global list --depth=0"

Checks For Outdated Packages

alias yo="yarn outdated"

Updates The Package Version

To change the prefix of the git tag you can use version-tag-prefix.

$ yarn config set version-tag-prefix "v"

Using the yarn version command you can update the version of your package via the command line.

$ yarn version
$ yarn version --major
$ yarn version --minor
$ yarn version --patch

======================= NEW REVISION

YARN

yarnpkg.com

yarn init

Create a new package

$ yarn init
$ yarn init -y

yarn add

Add dependencies to the project

$ yarn add <packageName>
$ yarn add -D <packageName>
$ yarn add -O <packageName>
$ yarn add -P <packageName>

$ yarn add <packageName>@<version>

yarn cache clean

Remove the shared cache files

$ yarn cache clean
$ yarn cache clean --mirror
$ yarn cache clean --all

yarn dlx

Run a package in a temporary environment

$ yarn dlx <packageTemporary>

yarn install

Install the project dependencies

$ yarn install

yarn link

Connect the local project to another one

$ yarn link <destination>
$ yarn link ~/jquery-folder

yarn run

Run a script defined in the package.json

$ yarn run <scriptName>

yarn up

Upgrade dependencies across the project

$ yarn up
$ yarn up <packageName>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment