pnpm and yarn are modern package managers that handle dependency installation, lockfile generation, and workspace linking for monorepos. lerna is a specialized tool focused on versioning, changelog generation, and publishing multiple packages from a single repository. While pnpm and yarn have replaced lerna for dependency installation, lerna remains relevant for managing release cycles. Choosing the right combination depends on whether you need strict dependency control, Plug'n'Play support, or automated publishing workflows.
Managing a repository with multiple packages requires tools that handle dependency installation, linking, and versioning. pnpm and yarn are package managers that install dependencies and link workspaces. lerna is a tool specifically designed to version and publish those packages. While their roles overlap historically, modern workflows often combine them. Let's compare how they handle core engineering tasks.
pnpm uses a content-addressable storage system.
// pnpm: .pnpmfile.cjs or default behavior
// No special config needed for store
// Installation command:
// pnpm install
yarn stores packages in a cache and links them to node_modules.
node_modules entirely.// yarn: .yarnrc.yml
nodeLinker: node-modules
# Installation command:
# yarn install
lerna does not install dependencies in modern versions.
pnpm or yarn for installation.lerna bootstrap, but this is now deprecated.// lerna: lerna.json
{
"version": "independent",
"npmClient": "pnpm"
}
// Installation command (delegated):
// pnpm install
pnpm requires a explicit workspace config file.
pnpm-workspace.yaml.workspace: protocol for local dependencies.# pnpm: pnpm-workspace.yaml
packages:
- "packages/*"
- "apps/*"
yarn defines workspaces directly in package.json.
workspaces key.// yarn: package.json
{
"workspaces": [
"packages/*",
"apps/*"
]
}
lerna uses lerna.json to define package locations.
// lerna: lerna.json
{
"packages": [
"packages/*",
"apps/*"
],
"version": "independent"
}
pnpm uses the -r flag to run scripts recursively.
# pnpm: Run build in all packages
pnpm -r run build
yarn uses the workspaces foreach command.
# yarn: Run build in all packages
yarn workspaces foreach -A run build
lerna uses lerna run to execute scripts.
--scope.# lerna: Run build in all packages
lerna run build --stream
pnpm relies on external tools like Changesets.
# pnpm: Using Changesets
pnpm changeset version
pnpm changeset publish
yarn also relies on external tools like Changesets.
# yarn: Using Changesets
yarn changeset version
yarn changeset publish
lerna has built-in versioning and publishing commands.
# lerna: Built-in versioning
lerna version
lerna publish
| Feature | pnpm | yarn | lerna |
|---|---|---|---|
| Primary Role | Package Manager | Package Manager | Versioning Tool |
| Install Command | pnpm install | yarn install | N/A (Delegate) |
| Workspace Config | pnpm-workspace.yaml | package.json | lerna.json |
| Run Scripts | pnpm -r | yarn workspaces foreach | lerna run |
| Versioning | External (Changesets) | External (Changesets) | Built-in (lerna version) |
| Disk Efficiency | ⭐⭐⭐ (Hard links) | ⭐⭐ (Cache) | N/A |
pnpm is the top choice for installation and workspace management.
lerna for publishing or Changesets for versioning.yarn is a strong alternative with unique features.
lerna for release management.lerna solves the release problem, not the install problem.
Final Thought: For most modern monorepos, use pnpm for installation and workspaces. Add lerna only if you need its specific versioning and publishing features. If you prefer yarn, the same logic applies — use it for installs and add lerna for releases if needed.
Choose lerna if you need automated versioning and publishing across multiple packages in a monorepo. It is best used alongside pnpm or yarn for installation, while lerna handles the release logic. It fits teams managing many libraries that need synchronized or independent version bumps.
Choose pnpm if you prioritize disk space efficiency and installation speed in a monorepo. It uses a content-addressable storage system that prevents duplicate packages across projects. It is ideal for teams that want strict dependency isolation to avoid missing declarations in package.json.
Choose yarn if you need Plug'n'Play (PnP) support or prefer the Berry ecosystem features. It offers strong workspace management and deterministic installs without requiring node_modules hoisting in PnP mode. It suits projects that want to move away from traditional module resolution.
Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Check out our docs site here.