Compare

pnpm vs npm: Speed, Disk Space and Strict Dependencies

November 16, 2026
pnpm
Open Source
VS
npm
Open Source

Pick pnpm if

You work in a monorepo or keep many JavaScript projects on one machine and want faster installs, less disk use and stricter dependency checks.

pnpm alternatives

Pick npm if

You want the package manager that already comes with Node.js, a flat node_modules folder by default and nothing extra to install.

npm alternatives
pnpm vs npm: Speed, Disk Space and Strict Dependencies

Both install the same packages from the same npm registry, and both are free and open source. The real differences are in how they lay out node_modules, how they store files on disk and how much they do for a repository with many packages in it.

pnpm vs npm at a glance

pnpmnpm
PriceFreeFree
Open sourceYes, MIT licenseYes, Artistic License 2.0
Comes with Node.jsNo, installed separatelyYes, the Node.js installer adds it
PlatformsPrebuilt binaries for Linux, macOS, Windows, FreeBSD, NetBSD and AndroidWherever Node.js is installed
Default node_modules layoutIsolated: only direct dependencies at the top, the rest linked from a storeHoisted: a flat folder where most packages sit at the top
Shared store across projectsYes, a content-addressable store with hard linksNo
Lockfilepnpm-lock.yamlpackage-lock.json
Best forMonorepos, CI, machines with many projectsSimple projects, beginners, anything that expects a flat node_modules

Is pnpm faster than npm?

In pnpm's own tests, yes. pnpm publishes a benchmarks page that installs two real test projects with npm and several pnpm setups. It covers six situations, from a fresh clone with nothing cached to running install when nothing has changed, and on that page pnpm beat npm in all six for both projects. Keep in mind whose page this is: the pnpm team runs the tests and picks the projects, and the numbers are rebuilt each time the site is deployed.

The reason for the gap is how pnpm installs. Its docs describe three stages: resolving dependencies, working out the node_modules structure, and linking files from its store. Each package moves to the next stage as soon as it is ready, without waiting for the others. pnpm contrasts this with the traditional approach of resolving everything, then fetching everything, then writing everything to node_modules.

The second reason is that pnpm often does not copy package files at all. If a package version is already in its store, pnpm links it into your project instead of downloading and writing it again.

Does pnpm really save disk space?

Yes, and the saving grows with the number of projects on your machine. pnpm's docs put it plainly: with npm, 100 projects that use the same dependency mean 100 copies of it on disk.

pnpm keeps every file in one content-addressable store. When you install, the files are hard-linked or cloned (copy-on-write) from that store into node_modules, so they take no extra space. pnpm only falls back to copying when the filesystem supports neither. When you update a package and only one file changed between versions, pnpm adds just that one new file to the store, not a full second copy of the package.

Two things can make this look wrong at first:

  • Folder sizes still look big. A hard link points at the same data on disk, so tools that add up folder sizes count the file twice. pnpm's FAQ explains that a 1 MB package shows up as 1 MB in the store and 1 MB in node_modules, but only uses 1 MB in total.
  • Different drives break the trick. Hard links cannot cross filesystems. If your store is on one drive and your project is on another, pnpm copies files instead of linking them. If you have not set a store path, pnpm creates one store per drive or filesystem.

What are phantom dependencies, and why does pnpm block them?

A phantom dependency is a package your code imports even though it is not listed in your package.json. It works only because some other package depends on it and the package manager placed it at the top of node_modules.

npm uses a hoisted layout by default. Its docs describe the default install strategy as placing packages "non-duplicated in top-level" and nesting them only when versions clash. pnpm's docs note the side effect: with a flat node_modules, your source code can reach packages you never added.

pnpm's default layout, which it calls isolated, puts only your direct dependencies at the top of node_modules. Everything else lives inside a hidden node_modules/.pnpm folder and is wired together with symlinks, as shown on pnpm's symlinked node_modules page. Node.js follows those symlinks to the real files, so normal imports still work. An import of something you never declared fails instead of working by accident.

npm can do this too. Its config docs list a linked install strategy, which stores packages in node_modules/.store and links them in place without hoisting. npm's own docs recommend that package authors use --install-strategy=linked during development to catch undeclared ("phantom") dependencies before publishing. The difference is the default: strict in pnpm, flat in npm.

Which is better for monorepos?

pnpm, for most teams. Both support workspaces. In npm you list them in the workspaces field of the root package.json and target one with a flag like --workspace=a.

pnpm declares workspaces in a pnpm-workspace.yaml file and adds more on top:

  • The workspace: protocol. A dependency like "foo": "workspace:*" can only resolve to the local package. If that package is missing, the install fails rather than quietly pulling a version from the registry. When you publish, pnpm replaces it with a normal version range.
  • Filtering. pnpm --filter runs a command on selected packages by name or pattern.
  • Catalogs. You define a version range once in pnpm-workspace.yaml and reference it as "react": "catalog:" in each package.json.

pnpm's workspace page lists large projects that use pnpm workspaces, including Next.js, Vite, Vue, Nuxt, Astro, Prisma and Angular. If your repository already lists projects in the workspaces field of package.json, pnpm 12.7.0 and later creates the pnpm-workspace.yaml for you on install.

How do the lockfiles differ?

npm writes package-lock.json and pnpm writes pnpm-lock.yaml. Both are meant to be committed so that teammates and CI install exactly the same tree.

The two formats are not interchangeable. pnpm's limitations page says it ignores package-lock.json, because npm's lockfile describes a flat layout that pnpm's isolated layout cannot follow. For CI, npm has npm ci, which needs an existing lockfile, deletes any existing node_modules and fails if the lockfile and package.json disagree. pnpm does the equivalent inside pnpm install: in a CI environment it fails if the lockfile needs an update. pnpm can also resolve merge conflicts in pnpm-lock.yaml itself when you run install after a conflicting merge.

What do they do with install scripts?

Both now hold back dependency install scripts until you approve them, but they react differently. In pnpm, packages not listed in its allowBuilds setting are not allowed to run build scripts, and by default the install stops with an error until you approve or deny them. npm 12's docs describe an allowScripts field in package.json for the same job; by default an unreviewed package's script is blocked with a warning, and the install only fails if you turn on strict-allow-scripts.

What we checked ourselves

We read the latest release of each tool straight from the npm registry. The latest tag pointed to pnpm 12.21.0 and npm 12.2.2. The package details showed one practical difference: the npm package declares that it needs Node.js 22.22.2 or later on the 22 line, 24.15.0 or later on the 24 line, or 26.0.0 and up. The pnpm package installs on Node.js 18 or newer, and pnpm's install page says pnpm 12 is a native executable that does not need Node.js at all once it is installed with the standalone script. The registry also listed pnpm's license as MIT and npm's as Artistic-2.0.

Will my project work with pnpm?

Most projects will. The usual breakage is a dependency that uses a package it never declared, which worked only because npm's flat layout hid the mistake. pnpm's FAQ gives three fixes: add the missing package to your own package.json, patch the broken package's dependencies with a hook or the packageExtensions setting, or set nodeLinker: hoisted to get a flat node_modules like npm's.

The hoisted setting is also pnpm's advice for tools that do not handle symlinks, for serverless hosts that do not support them (pnpm names AWS Lambda), and for running Node.js with --preserve-symlinks. On Windows, pnpm uses junctions when it cannot create symlinks. One Windows note from pnpm's install page: Windows Defender sometimes blocks the standalone installer, so pnpm currently recommends installing it with npm on Windows.

How do you switch from npm to pnpm?

  1. Install pnpm. On Windows, use npm install -g pnpm@latest. Elsewhere you can also use the standalone script from pnpm's installation page, which does not need Node.js.
  2. If you use workspaces, declare them in pnpm-workspace.yaml first.
  3. Run pnpm import. It reads your package-lock.json and writes a pnpm-lock.yaml, preferring the versions npm already resolved. It is not a one-to-one conversion, so check the result.
  4. Run pnpm install, then your tests. Fix any missing-dependency errors with the steps above.
  5. Commit pnpm-lock.yaml and remove package-lock.json so the team uses one lockfile.

What about Corepack?

Corepack is a small Node.js tool that lets you use Yarn, npm and pnpm without installing them, running the version a project pins in the packageManager field of package.json. The Corepack README says it was distributed with Node.js from 14.19.0 up to, but not including, 25.0.0. On newer Node.js versions you install it yourself with npm install -g corepack.

pnpm now covers this on its own. Its feature comparison lists managing versions of itself as something pnpm does and npm does not, and pnpm self-update only updates the pinned version when a project sets packageManager. npm itself still arrives with Node.js, so it needs neither.

If you are weighing other options too, see our lists of npm alternatives and pnpm alternatives.

Which should you choose?

  • You run a monorepo: pnpm, for the workspace: protocol, filtering and catalogs.
  • You have many projects on one laptop or a busy CI cache: pnpm, because files are stored once and linked.
  • You want mistakes like undeclared imports caught early: pnpm by default, or npm with the linked install strategy.
  • You are learning Node.js or have a small project: npm, since it is already installed.
  • Your tooling or host cannot handle symlinks: npm, or pnpm with nodeLinker: hoisted.

FAQ

Can I use pnpm with packages from the npm registry?

Yes. pnpm installs the same packages from the same registry. Only the layout on disk and the lockfile differ.

Can pnpm read package-lock.json?

Not during install; it ignores it. Run pnpm import once to turn it into pnpm-lock.yaml.

Does pnpm work on Windows?

Yes. pnpm ships Windows binaries for x64 and arm64 and uses junctions when it cannot create symlinks.

What does pnpm stand for?

Performant npm, according to pnpm's own FAQ.

How we compare: prices, plans and features come from each product’s official site, pricing page or app store listing. See how we write.

See the alternatives

More comparisons: developer tools and hosting

Muhammad Mairaj
Muhammad Mairaj
Muhammad Mairaj is a Senior Backend Engineer and Partner at Webstribe, a brand of Softstribe Solutions, where he handles the backend and infrastructure and writes the technical guides. He is also a Senior Software Engineer (Backend) at Funavry Technologies in Islamabad, with 8 years of experience including payments at NayaPay.
More from Muhammad Mairaj →