Skip to content

Yarn

"Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered."

CLI commands

Docs available here

  • yarn add
  • yarn bin
  • yarn cache clean
  • yarn config [get / set / unset]
  • yarn constraints [query / source]
  • yarn dedupe
  • yarn dlx
  • yarn exec

Import

"Generates yarn.lock from an npm package-lock.json file in the same location or an existing npm-installed node_modules folder." ((more)[https://classic.yarnpkg.com/en/docs/cli/import/])

yarn import

Adding globally

Adding the serve package for example...

yarn global add serve

Workspaces

"Yarn Workspaces is a way to setup package architecture where all packages dependencies are installed together with a single yarn install."

Great example using workspaces at the following: https://github.com/austintgriffith/scaffold-eth/tree/local-optimism

yarn workspaces list

Cleaning Cache (from .yarn directory)

yarn cache clean

Steps for resolving yarn.lock merge conflicts

git checkout main
git pull
git checkout feature-branch
git merge main
git checkout —theirs yarn.lock
yarn
git add yarn.lock
git commit -m “resolving yarn.lock merge conflicts”
git push orgiin feature-branch

yarn pack

"Creates a compressed gzip archive of the package dependencies." ((more)[https://classic.yarnpkg.com/en/docs/cli/pack/])