Skip to content
Latchkey

Yarn Cheat Sheet: Classic & Berry Commands

Yarn commands for Classic and Berry, side by side, in one reference.

Install, run, and manage workspaces with Yarn.

Core commands

CommandDoes
yarn installInstall dependencies
yarn install --immutableCI install (Berry), no lockfile change
yarn add pkgAdd a dependency
yarn add -D pkgAdd devDependency
yarn remove pkgRemove a dependency
yarn <script>Run a script directly
yarn dlx pkgRun binary without install (Berry)

Workspaces

CommandDoes
yarn workspaces listList workspaces (Berry)
yarn workspace app add pkgAdd dep to one workspace
yarn workspaces foreach run buildRun across workspaces (Berry)

Classic vs Berry

ConcernNote
CI installClassic: --frozen-lockfile / Berry: --immutable
Run scriptsyarn run name or just yarn name
PnPBerry default; .yarn/cache replaces node_modules

Key takeaways

  • Berry uses --immutable; Classic uses --frozen-lockfile for CI.
  • yarn <script> runs a script without the explicit run keyword.
  • Berry Plug n Play removes node_modules in favor of .yarn/cache.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →