pnpm uses hard links and a content-addressable store. 100 projects sharing lodash? One copy on disk. Install times are 2x faster than npm.
The npm Problem
npm install in 10 projects = 10 copies of every dependency. A typical React project has 500MB in node_modules. Ten projects = 5GB of duplicate packages.
pnpm: one global store, hard links to each project. Same packages, zero duplication.
What You Get for Free
Content-addressable storage — each package version stored ONCE globally
Hard links — projects reference the global store, no copying
Strict node_modules — packages can only access declared dependencies (no phantom deps)
2x faster installs — less to download, less to write to disk
Built-in monorepo support — workspaces without extra tools
Quick Start
npm install -g pnpm
pnpm install # drop-in replacement for npm install
Every npm command works: pnpm add, pnpm run, pnpm test. Same interface, better performance.
Disk Space Savings
Real numbers from a developer with 50 projects:
- npm: 25GB in node_modules
- pnpm: 5GB (one global store + hard links)
- Savings: 80%
Strict Dependencies (Why This Matters)
npm has a flat node_modules structure. This means:
// Your package.json only has 'express'
// But you can accidentally import express's internal dependency:
import qs from 'qs'; // works with npm, breaks if express drops qs
pnpm uses a nested structure with symlinks. Only YOUR declared dependencies are accessible. This catches phantom dependency bugs before production.
Monorepo Workspace
# pnpm-workspace.yaml
packages:
- 'apps/*'
- 'packages/*'
pnpm -r run build # build all packages
pnpm --filter app-web build # build specific package
pnpm add lodash --filter app-api # add dep to specific package
No Lerna needed. Workspaces are first-class in pnpm.
If you're using npm — switch to pnpm in 30 seconds and never look back.
Need web scraping or data extraction? Check out my tools on Apify — get structured data from any website in minutes.
Custom solution? Email spinov001@gmail.com — quote in 2 hours.
Top comments (0)