Hint
pnpm hoists deps once via hard links — saves disk space and prevents phantom dependencies vs npm/yarn workspaces
pnpm workspaces link all packages in a monorepo together so they can import each other as if they were published packages, while sharing a single node_modules store.
# pnpm-workspace.yaml
packages:
- 'apps/*'
- 'packages/*'
Why pnpm over npm/yarn workspaces:
1. Hard-link store — pnpm stores each package version once globally and hard-links into projects. A 100-package monorepo doesn't duplicate React 100 times on disk.
2. Strict dependency resolution — pnpm only allows importing packages listed in a package's own package.json. npm/yarn hoist everything, enabling "phantom dependencies" (importing a transitive dep that isn't declared — breaks when the transitive dep is removed).
3. Speed — hard links are faster to set up than copies; install times drop 2–5× vs npm on large repos.
4. Filtering — pnpm --filter @org/ui build runs a command in just one package; pnpm -r build runs it across all.