We are migrating our repositories to use pnpm in place of yarn. This page aims to explain the reasoning behind the change and provide guidance on day-to-day work with the new package manager.

Why are we doing this?

Checkout task with Yarn

Checkout task with Yarn

Checkout task with pnpm

Checkout task with pnpm

What are the main differences to Yarn?

Installation

Follow the guidelines at https://pnpm.io/installation. The Corepack method seems to be working well despite being experimental.

After installation, remove the node_modules directory and run pnpm i to create the pnpm package store.

Useful commands

Yarn pnpm
yarn, yarn install pnpm i, pnpm install Installs dependencies. Note that (similarly to npm), you can’t run just pnpm to do this.
yarn add, yarn add --dev pnpm add,
pnpm add -D Adds a dependency to the current project’s package.json. Running this in the root will trigger a warning (as having dependencies in a root package.json is discouraged), that can be dismissed with a -w flag.
yarn workspace X Y pnpm --filter X Y Runs a command Y from a specific package X. In pnpm you can provide a filter matching multiple packages (https://pnpm.io/filtering).
yarn X, yarn run X pnpm X, pnpm run X Runs a script from the current package.json. It’s also possible to run a script from all the workspace projects that define it with the -r flag (for example pnpm build -r will run the build script from all workspace projects, not the root one).
yarn test pnpm test, pnpm t Runs the script named “test”.
Note: pnpm defines the t alias for this command that conflicts with our “t” script (the test CLI). Executing pnpm t won’t run the “t” script but the “test” one. To run the test CLI, execute pnpm run t.
pnpm patch Lets you patch broken dependencies (e.g., while waiting for the maintainers to merge a PR). See https://pnpm.io/cli/patch for more details.