Stop 17 · Build ToolsTopics · 8/9

PNPM

Part of the Frontend Developer Roadmap

In short

Ten projects on your laptop, each with its own heavy node_modules folder? pnpm keeps one shared copy of each package version and links it everywhere, so installs are faster and lighter.

A fast, disk-space-efficient package manager that uses a shared, content-addressable store so identical dependencies aren't duplicated across projects.

The jaadu librarian hands out cards that point to single copies of books on one shelf.

Think of it like this

Hostel library vs buying every book

Imagine every hostel room buying its own copy of the same textbook. Wasteful, right? pnpm is the hostel library: one copy on the shelf, and every room gets a card pointing to it.

Watch it happen

One copy, many projects

Project A
pnpm
Store
Project B

pnpm add zod

1/6Project A asks for zod.

The big ideas

What you need to know

One global store

Each package version is saved once on your disk. Projects link to it with hard links instead of copying.

Strict node_modules

Your code can import only packages you actually listed. No accidental use of a dependency's dependency.

Great for monorepos

pnpm-workspace.yaml lets one repo hold many packages that share installs and link to each other.

Its own lock file

pnpm writes pnpm-lock.yaml. Commit it, just like package-lock.json.

See it in code

Walk through the code

bash
1corepack enable          # lets Node manage pnpm for you2pnpm install             # install everything in package.json3pnpm add zod             # add a dependency4pnpm add -D vitest       # add a dev dependency5pnpm dev                 # run the "dev" script6 7# In CI: fail if the lock file is out of date8pnpm install --frozen-lockfile

1/4Let Node's Corepack provide the pnpm version your project expects.

Corepack ships with Node and reads the packageManager field in package.json, so everyone on the team uses the same pnpm version.

Save yourself the pain

Common mistakes

Oops

Importing a package you never added, because it worked with npm.

Do this instead

With npm it worked by luck, since another package installed it. Run pnpm add for every package you import.

Oops

Mixing npm install and pnpm install in the same project.

Do this instead

Pick one package manager per project. Mixing creates two lock files and confusing node_modules.

Your mission

Switch one project to pnpm

~20 min

Quick check

After moving to pnpm, your app fails with "Cannot find module 'lodash'", though it worked with npm. Why?

Go deeper

  1. 1Install pnpm and try it on an existing project (`pnpm install`).
  2. 2Compare `node_modules` disk usage and install speed vs npm.
  3. 3Learn how its strict, non-flat `node_modules` structure prevents 'phantom dependency' bugs.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge