Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Three package managers, all working. npm is built into Node and 'just works' but is slow on large monorepos. yarn (especially v3+ Berry) is fast but has a flatter community. pnpm is the 2026 winner: it uses a content-addressed global store + symlinks so installs are 2-3× faster and disk-cheap, has the best workspace support, and is officially recommended by Vercel, Vite, etc. Pick pnpm for new projects unless your team has a specific reason otherwise.
npm, yarn, and pnpm solve the same problem — installing packages — but with meaningfully different strategies for deduplication and disk efficiency. npm uses a flat node_modules tree that can balloon to gigabytes in a large monorepo because each package gets its own copy of shared dependencies; pnpm uses a global content-addressable store and symlinks, meaning 100 projects can share one copy of React on disk. Measuring install time and disk footprint across all three on a real project gives you the empirical basis to make an informed choice rather than cargo-culting whatever your last project used.
corepack enable && corepack prepare pnpm@latest --activate.pnpm install on the same project that previously used npm. Time both — pnpm should be 2-4× faster on warm cache.node_modules after pnpm install. Note it's mostly symlinks into ~/.local/share/pnpm/store — that's the magic.pnpm-workspace.yaml with packages: ["apps/*", "packages/*"]. Now you have a monorepo. We'll use this in M6.Use these three in order. Each builds on the one before.
In one paragraph, explain why pnpm is faster than npm — the content-addressed store, symlinks, and parallel resolution.
Walk me through how pnpm's symlink layout in `node_modules` differs from npm's flat layout. Why doesn't this break Node's module resolution?
On a monorepo with 50 packages, pnpm should win. But there's a known incompatibility class — packages that don't expect symlinks. What are the symptoms and how do I work around them?
# npm (default):
$ time npm install
real 0m24.531s
$ du -sh node_modules
312M
# yarn (v1 classic):
$ time yarn install
real 0m18.012s
$ du -sh node_modules
298M
# pnpm — content-addressed store + symlinks:
$ time pnpm install
real 0m6.401s # 4× faster
$ du -sh node_modules
84M # 4× smaller
$ ls -la node_modules/fastify
lrwxr-xr-x ... fastify -> ../../.pnpm/fastify@4.27.0/node_modules/fastify
# pnpm workspaces:
$ cat pnpm-workspace.yaml
packages:
- "apps/*"
- "packages/*"node main.js