Yarn Berry vs pnpm: Modern JS Package Managers
Pick pnpm for a fast, disk-efficient node_modules via a content-addressable store with strict dependency isolation; pick Yarn Berry if you want Plug n Play, zero-installs, and its plugin and constraints system.
Yarn Berry (Yarn 2 and later) and pnpm are both fast, modern alternatives to npm with strong monorepo support. They differ most in how they place dependencies on disk. pnpm uses a global content-addressable store and symlinks, giving a strict, non-flat node_modules. Yarn Berry defaults to Plug n Play (PnP), which can skip node_modules entirely.
| Yarn Berry | pnpm | |
|---|---|---|
| Install model | PnP (default) or node-modules linker | Symlinks from a global store |
| Disk usage | Low (zero-installs cache) | Low (hard-linked store) |
| Strictness | Strict under PnP | Strict (no phantom deps) |
| Workspaces | Yes (mature) | Yes (mature) |
| Compatibility | PnP can need patches for some tools | High (real node_modules layout) |
| Extras | Plugins, constraints, zero-installs | pnpm-lock.yaml, catalogs |
Where each genuinely wins
pnpm wins on broad compatibility because its symlinked node_modules looks like a normal layout to most tools, while still preventing access to undeclared (phantom) dependencies. Yarn Berry wins if you want PnP zero-installs (committing the cache so yarn install is nearly instant in CI) plus its constraints and plugin ecosystem.
In CI
Both cache well. pnpm restores fast from its store and pnpm install --frozen-lockfile enforces the lock. Yarn Berry with zero-installs can make CI installs almost free because the cache is committed, though that grows the repo. Both support --immutable/--frozen-lockfile to fail on lockfile drift, which you want in CI.
Honest caveats
PnP improves correctness but some tools assume a physical node_modules and need the node-modules linker or patches, which is friction. pnpm is generally the lower-surprise choice for mixed toolchains, but its strictness can surface real bugs (undeclared deps) that a flat npm tree hid.
The verdict
Choose pnpm for the smoothest path to fast, strict installs that just work with existing tools. Choose Yarn Berry if you specifically want PnP zero-installs or its plugin and constraints features and accept occasional compatibility work.