What is pnpm and Why Use It

Have you ever waited 5 minutes for npm install? Or discovered your node_modules folder eating 2GB of disk space across 20 projects? pnpm fixes both of these problems that drive developers insane.

Released in 2016, pnpm uses a content-addressable storage system where packages are stored once globally and linked to projects. When you install lodash in 100 projects, pnpm stores it only once on disk and creates hard links to each project's node_modules. No more copying the same damn files over and over.

How pnpm Fixes npm's Biggest Problems

pnpm Store Architecture

Unlike npm and Yarn Classic that copy the same packages over and over, pnpm's non-flat node_modules structure prevents the "phantom dependencies" problem that bites you in production. Each package can only access dependencies it actually declares in package.json. This catches dependency issues during development instead of when your app crashes at 3am.

The downside? pnpm's symlinks break some IDEs and debuggers. VS Code sometimes can't resolve imports correctly, and you'll spend time figuring out if it's a real dependency issue or just your editor getting confused by the symlink maze.

Real Performance Numbers

In my testing, pnpm is way faster than npm. Like stupidly faster:

  • Clean installs: 2-3x faster than npm
  • Cached installs: happen in under a second vs npm's forever
  • Disk usage: about half the space

pnpm Benchmark Chart

Your results depend on project size and how many shared dependencies you have. The more overlap between projects, the bigger pnpm's advantage gets.

Who Actually Uses This

Microsoft's Rush team recommends pnpm for monorepos with hundreds of projects because it handles phantom dependencies better than npm. Rush supports all three package managers, but their docs basically say "use pnpm if you want your builds to be predictable."

Current sponsors include Discord, Vite, Stackblitz, and Vercel - companies that deal with massive JavaScript codebases and got tired of waiting for npm.

Monorepo Support That Actually Works

pnpm Workspace Configuration

pnpm includes built-in workspace support so you don't need to cobble together Lerna + npm + whatever else. Create a pnpm-workspace.yaml file and you get dependency hoisting controls, workspace protocols, and shared version management.

The workspace catalogs feature lets you define dependency versions once and reuse them across packages. No more hunting down every package.json to update React.

Package Manager Feature Comparison

Feature

pnpm

npm

Yarn Classic

Yarn Berry

Installation Speed

⚔ Actually fast

Slow as hell

Fast but finicky

Fast but breaks things

Disk Space Usage

šŸŽÆ Way less space

Wasteful

Same waste as npm

Decent

Dependency Structure

Non-flat, strict

Flat mess

Flat mess

PnP (no node_modules)

Phantom Dependencies

āœ… Prevented

āŒ Allows broken code

āŒ Allows broken code

āœ… Prevented

Monorepo Support

āœ… Built-in

āœ… Workspaces

āœ… Workspaces

āœ… Advanced

Symlinks/Hard Links

āœ… Hard links

āŒ File copies

āŒ File copies

āœ… Zero-installs

Lock File Format

pnpm-lock.yaml

package-lock.json

yarn.lock

yarn.lock

Node.js Version Manager

āœ… Built-in

āŒ Separate tool

āŒ Separate tool

āŒ Separate tool

Peer Dependencies

āœ… Auto-installed

Manual prompts

āœ… Auto-installed

āœ… Advanced

Cache Strategy

Content-addressable

Hash-based

Hash-based

Global cache

Workspace Protocols

āœ… Advanced

Basic

Basic

āœ… Advanced

Dependency Catalogs

āœ… Built-in

āŒ None

āŒ None

āœ… Constraints

Windows Support

āœ… Full

āœ… Full

āœ… Full

āœ… Full

Industry Adoption

Growing fast

Still everywhere

Dead but won't die

Niche but powerful

Getting Started with pnpm

Installation (What Actually Works)

The official installer script usually works fine:

## Using curl (macOS/Linux)
curl -fsSL https://get.pnpm.io/install.sh | sh -

## Using PowerShell (Windows)
iwr https://get.pnpm.io/install.ps1 -useb | iex

If that fails (corporate firewall, weird proxy, etc.), fall back to npm global installation:

## Via npm - slower but more reliable
npm install -g pnpm

Corepack is nice when it works, but Node version managers like nvm can be finicky:

## Via Corepack (Node.js 16.13+) - YMMV
corepack enable
corepack prepare pnpm@latest --activate

pnpm Installation Methods

Essential Commands

pnpm maintains familiar npm-like syntax while adding powerful extensions:

## Install dependencies
pnpm install          # or pnpm i

## Add packages
pnpm add react        # production dependency
pnpm add -D vitest    # development dependency

## Run scripts
pnpm run build        # or pnpm build
pnpm start

## Update packages
pnpm update           # all packages
pnpm update react     # specific package

Workspace Configuration

For monorepo projects, create a pnpm-workspace.yaml file in the repository root:

packages:
  - 'packages/*'
  - 'apps/*'
  - '!**/test/**'

This configuration enables workspace features like cross-package dependencies and filtering:

## Install workspace dependency
pnpm add @myorg/shared-utils --workspace

## Run command in specific workspace
pnpm --filter @myorg/web-app build

## Run command in all workspaces
pnpm -r build

The filtering system supports complex patterns and dependency-based execution, making it more powerful than Lerna's filtering.

Migration Reality Check

Migration works great until your CI breaks, your Docker builds fail, and that one legacy package starts throwing "Module not found" errors. Here's what actually happens:

  1. Remove node_modules and lock files
  2. Run pnpm install and see what breaks
  3. Fix CI scripts (use pnpm install --frozen-lockfile not npm ci)
  4. Add node-linker=hoisted to .npmrc when things break

Some packages make wrong assumptions about dependency access - they'll fail with cryptic module resolution errors. Packages like react-native and electron assume npm's flat structure and will shit the bed with helpful messages like "Module not found" for dependencies that should be there.

The node-linker=hoisted setting brings back npm's flat structure as a compatibility escape hatch, but this defeats half the point of using pnpm.

Docker builds need different commands: pnpm install --frozen-lockfile instead of npm ci. Your Dockerfile probably breaks on the first try. Docker layer caching gets weird with pnpm's symlinks - your build times might actually get worse until you fix the Dockerfile.

Windows shits the bed with pnpm's deep directory structures - file path limits hit you way faster. And version upgrades sometimes break the store and you have to nuke everything and reinstall.

pnpm Docker Setup

Configuration Options

pnpm's behavior can be customized through .npmrc files at project or global levels:

## Enable hoisting for compatibility
node-linker=hoisted

## Strict peer dependencies
auto-install-peers=false

## Custom registry
registry=https://registry.npmjs.org/

## Workspace isolation
link-workspace-packages=false

These settings give you fine-grained control over dependency resolution, linking behavior, and workspace interactions for different project requirements.

Frequently Asked Questions

Q

Is pnpm compatible with existing npm projects?

A

Mostly yes, until you hit that one package that makes assumptions about npm's messy structure. Then you'll spend an hour figuring out why imports are failing.The good news: your package.json works without changes. The bad news: styled-components v4 will break because it tries to access React directly instead of through peer deps, and you'll get "Module not found" errors for dependencies that should be there.Quick fix: add node-linker=hoisted to .npmrc and pnpm brings back npm's sloppy flat structure. This defeats half the point of using pnpm, but at least your app works.

Q

How does pnpm handle peer dependencies?

A

pnpm auto-installs peer dependencies by default, which is great until you get version conflicts.

Unlike npm's useless warnings, pnpm actually tries to fix the problem

  • sometimes this helps, sometimes it breaks your project in creative new ways.You'll know pnpm's peer dependency resolution is confused when you see error messages like Could not resolve dependency: peer react@"^17.0.0" from styled-components@5.3.0. This means some package declared React 17 as a peer dep but you're running React 18.
Q

Why doesn't my package work with pnpm's strict node_modules?

A

Because that package is poorly written and makes assumptions about npm's flat structure mess.

It's trying to import dependencies it never declared in package.json

  • a bug that npm hides but pnpm catches.Specific packages that will shit the bed:

  • react-native assumes npm's flat structure and can't find native modules

  • electron apps often break because they bundle node_modules and pnpm's symlinks don't survive

  • jest sometimes can't find modules because of pnpm's strict resolution

  • Any package using patch-package gets confused by pnpm's linkingQuick fix: add node-linker=hoisted to .npmrc.

Long-term: file bugs against these packages for violating Node.js module resolution.

Q

Can I use pnpm with Docker?

A

Yes, but your Dockerfile will probably break the first try.

Docker layer caching gets weird with pnpm's symlinks, and your build times might actually get worse until you fix it.Common gotcha: pnpm's symlinks don't work in multi-stage Docker builds.

You'll get ENOENT: no such file or directory errors when copying from previous stages.

Fix your Dockerfile:dockerfile# This breaksCOPY package.json pnpm-lock.yaml ./RUN pnpm install# This worksCOPY package.json pnpm-lock.yaml ./RUN pnpm install --frozen-lockfileCOPY . .Windows containers are even more fun

  • file path limits hit you faster with pnpm's deep directory structures.
Q

How much disk space does pnpm actually save?

A

50-80% savings sounds great until you realize pnpm's store lives in a hidden directory eating space anyway.

The real benefit kicks in when you have 20+ projects sharing dependencies.Reality check: if you only have 2-3 projects, the space savings are minimal. The speed improvement is where pnpm shines

  • cached installs happen in seconds vs npm's forever.
Q

What happens when pnpm's store gets corrupted?

A

The store corrupts more than you'd expect, especially on Windows or if you Ctrl+C during installs.

You'll get cryptic "integrity check failed" errors or packages that refuse to install with helpful messages like ERR_PNPM_STORE_BREAKING_CHANGE.Nuclear options that actually work:

  • pnpm store prune
  • removes unused stuff, sometimes fixes corruption
  • rm -rf ~/.pnpm-store && pnpm install
  • nukes everything, slow but reliable
  • On Windows: delete %LOCALAPPDATA%\pnpm\store and start over

Budget 30 minutes for store corruption debugging if you're lucky, 2 hours if the corruption is deep. It happens often enough that you'll memorize these commands.

Q

Does pnpm work with CI/CD systems?

A

Yes, but CI setup is where pnpm gets finicky.

Use pnpm install --frozen-lockfile or your builds become non-deterministic.GitHub Actions gotcha: the setup-pnpm action sometimes installs the wrong version. Pin the version explicitly or spend debugging time later.Our CI broke twice during pnpm adoption

  • once because I forgot to change npm ci to pnpm install --frozen-lockfile, and once because the cache key still referenced package-lock.json instead of pnpm-lock.yaml
Q

Can I migrate from npm/Yarn without issues?

A

Migration works great until your CI breaks, your Docker builds fail, and that one legacy package starts throwing "Module not found" errors.

Budget a full day for fixing weird edge cases.The migration dance:

  1. rm -rf node_modules package-lock.json yarn.lock2. pnpm install3.

Watch half your tooling break 4. Add node-linker=hoisted to .npmrc5. Feel guilty about defeating pnpm's main featureCommon migration casualties: ESLint configs, Jest setups, anything that patches node_modules directly.

Check pnpm import for importing existing lockfiles.

Q

How does pnpm compare to Yarn Berry's Plug'n'Play?

A

Both solve phantom dependencies, but Yarn PnP is faster and breaks way more things. pnpm breaks maybe 10% of packages; Yarn PnP breaks like 40%.If your tooling is newer and well-maintained, Yarn PnP is blazingly fast. If you use any legacy packages or custom build setups, pnpm is the safer bet.Bottom line: pnpm for compatibility, Yarn PnP if you enjoy fixing broken tooling and want maximum performance.

Q

Is pnpm suitable for enterprise environments?

A

Yes, if your enterprise can handle occasional weirdness.

We've had pnpm break twice in production

  • once during a major version upgrade that broke our Docker layer caching, and once because someone Ctrl+C'd an install and corrupted the store during a deploy, killing the whole pipeline for 3 hours.The good: strict dependency resolution catches supply chain issues npm misses.

The bad: when pnpm breaks, it breaks in creative ways that take hours to debug.

The ugly: explaining to your manager why switching package managers caused a 4-hour outage.

Q

What Node.js versions does pnpm support?

A

Node 16.14+ officially, but pnpm gets finicky with newer Node versions before they fix compatibility. Node 20.x had symlink issues on Windows for months.The built-in Node version manager is nice when it works, but nvm is more reliable. Don't depend on pnpm's Node management for anything critical.

Q

How do I troubleshoot pnpm installation issues?

A

First, try the obvious stuff:

  1. pnpm store prune
  • clears cache corruption (takes forever but fixes weird shit)2.

Delete node_modules and reinstall (the classic "delete node_modules" solution)3. Check if your antivirus is fucking with symlinks

  • this actually happens on Windows more than you'd think
  1. Verify .npmrc isn't misconfigured
  • one wrong setting breaks everything

If that fails, pnpm's error messages are actually helpful

  • read them. Unlike npm's cryptic bullshit, pnpm tells you what's wrong and suggests fixes.Last resort: nuke the store directory and start fresh. Takes forever but fixes 90% of weird issues.

Essential pnpm Resources

Related Tools & Recommendations

compare
Similar content

Bun vs Node.js vs Deno: JavaScript Runtime Performance Comparison

Three weeks of testing revealed which JavaScript runtime is actually faster (and when it matters)

Bun
/compare/bun/node.js/deno/performance-comparison
100%
compare
Recommended

Pick Your Monorepo Poison: Nx vs Lerna vs Rush vs Bazel vs Turborepo

Which monorepo tool won't make you hate your life

Nx
/compare/nx/lerna/rush/bazel/turborepo/monorepo-tools-comparison
99%
troubleshoot
Similar content

npm Threw ERESOLVE Errors Again? Here's What Actually Works

Skip the theory bullshit - these fixes work when npm breaks at the worst possible time

npm
/troubleshoot/npm-install-error/dependency-conflicts-resolution
98%
tool
Similar content

npm - The Package Manager Everyone Uses But Nobody Really Likes

It's slow, it breaks randomly, but it comes with Node.js so here we are

npm
/tool/npm/overview
87%
troubleshoot
Similar content

Solve npm EACCES Permission Errors with NVM & Debugging

Learn how to fix frustrating npm EACCES permission errors. Discover why npm's permissions are broken, the best solution using NVM, and advanced debugging techni

npm
/troubleshoot/npm-eacces-permission-denied/eacces-permission-errors-solutions
84%
troubleshoot
Recommended

Fix Yarn Corepack "packageManager" Version Conflicts

Stop Yarn and Corepack from screwing each other over

Yarn Package Manager
/tool/troubleshoot/yarn-package-manager-error-troubleshooting/corepack-version-conflicts
60%
compare
Recommended

Nx vs Turborepo: Which One Actually Sucks Less?

After 8 months in monorepo hell, here's what actually works

Nx
/compare/nx/turborepo/build-performance-comparison
57%
tool
Similar content

uv Python Package Manager: Overview, Usage & Performance Review

Discover uv, the high-performance Python package manager. This overview details its core functionality, compares it to pip and Poetry, and shares real-world usa

uv
/tool/uv/overview
56%
tool
Similar content

Poetry - Python Dependency Manager: Overview & Advanced Usage

Explore Poetry, the Python dependency manager. Understand its benefits over pip, learn advanced usage, and get answers to common FAQs about dependency managemen

Poetry
/tool/poetry/overview
53%
tool
Similar content

Helm: Simplify Kubernetes Deployments & Avoid YAML Chaos

Package manager for Kubernetes that saves you from copy-pasting deployment configs like a savage. Helm charts beat maintaining separate YAML files for every dam

Helm
/tool/helm/overview
51%
tool
Similar content

Node.js Memory Leaks & Debugging: Stop App Crashes

Learn to identify and debug Node.js memory leaks, prevent 'heap out of memory' errors, and keep your applications stable. Explore common patterns, tools, and re

Node.js
/tool/node.js/debugging-memory-leaks
49%
tool
Similar content

Fastify Overview: High-Performance Node.js Web Framework Guide

High-performance, plugin-based Node.js framework built for speed and developer experience

Fastify
/tool/fastify/overview
49%
compare
Similar content

Uv vs Pip vs Poetry vs Pipenv: Performance Comparison & Guide

I spent 6 months dealing with all four of these tools. Here's which ones actually work.

Uv
/compare/uv-pip-poetry-pipenv/performance-comparison
45%
tool
Similar content

Node.js Performance Optimization: Boost App Speed & Scale

Master Node.js performance optimization techniques. Learn to speed up your V8 engine, effectively use clustering & worker threads, and scale your applications e

Node.js
/tool/node.js/performance-optimization
45%
tool
Similar content

Express.js - The Web Framework Nobody Wants to Replace

It's ugly, old, and everyone still uses it

Express.js
/tool/express/overview
45%
tool
Similar content

Bun JavaScript Runtime: Fast Node.js Alternative & Easy Install

JavaScript runtime that doesn't make you want to throw your laptop

Bun
/tool/bun/overview
43%
tool
Similar content

Node.js Security Hardening Guide: Protect Your Apps

Master Node.js security hardening. Learn to manage npm dependencies, fix vulnerabilities, implement secure authentication, HTTPS, and input validation.

Node.js
/tool/node.js/security-hardening
42%
tool
Similar content

npm Enterprise Troubleshooting: Fix Corporate IT & Dev Problems

Production failures, proxy hell, and the CI/CD problems that actually cost money

npm
/tool/npm/enterprise-troubleshooting
42%
tool
Similar content

Node.js Overview: JavaScript on the Server & NPM Ecosystem

Run JavaScript outside the browser. No more switching languages for frontend and backend.

Node.js
/tool/node.js/overview
40%
tool
Similar content

Docker: Package Code, Run Anywhere - Fix 'Works on My Machine'

No more "works on my machine" excuses. Docker packages your app with everything it needs so it runs the same on your laptop, staging, and prod.

Docker Engine
/tool/docker/overview
37%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization