pnpm vs npm: The Real Reason to Switch Isn't Speed
pnpm vs npm in November 2026: pnpm 12.21.0 against npm 12.2.3. pnpm installs 3x to 174x faster in its own benchmark, but the better reason to switch is that npm's flat node_modules lets your code import packages you never declared. npm 12 now blocks dependency install scripts by default, which narrows the safety gap and leaves the layout gap.
Key takeaways
- On November 18, 2026 the current releases are pnpm 12.21.0 and npm 12.2.3, and the core difference is layout: npm hoists every package into one flat node_modules folder, while pnpm keeps a global content-addressable store and symlinks only the dependencies each package declared.
- A phantom dependency is a package your code imports successfully even though it was never declared in package.json, which happens because npm hoists transitive dependencies to the top of node_modules; pnpm prevents it structurally because Node ignores symlinks when resolving modules.
- In pnpm's own benchmark run on November 17, 2026, a fresh-clone install of a one-gigabyte project of 14 toolchains took 1 minute 44 seconds with npm 12.2.2 and 14.4 seconds with pnpm 12.21.0, about 7x faster, and pnpm won all six scenarios by 3x to 174x.
- npm 12, released July 8, 2026, blocks dependency install scripts unless the root package approves them through allowScripts and defaults allow-git to none, which closes most of the build-script safety gap with pnpm but leaves the hoisted layout and the missing one-day release delay as the remaining differences.
- Two lockfiles in one repo is its own bug class: platforms like Vercel, Netlify, and AWS Amplify detect the package manager from lockfile presence, so a stray package-lock.json in a pnpm repo can silently build a different dependency tree in production than the one you run locally.
pnpm vs npm comes down to one design decision. npm 12, the package manager that ships with Node.js, hoists every package into one flat node_modules folder.
pnpm 12 keeps one global store and symlinks into each project only the packages that project declared, so it installs several times faster and refuses to let your code import anything missing from package.json.
Use pnpm for anything you will maintain, and keep npm for a throwaway script or a machine where you can't install a second tool. The versions behind this piece are pnpm 12.21.0 and npm 12.2.3, the current releases on November 18, 2026.[19]
I lost an afternoon last year to a bug that didn't exist anywhere I could see. The build was green on my laptop. Tests passed in CI (continuous integration).
Production threw Cannot find module 'lodash.merge' the first time real traffic hit a code path I rarely exercised, even though three files in the codebase imported lodash.merge and the tests had imported them. I'd never put lodash.merge in package.json.
Somewhere in some install order, npm had hoisted it (pulled it up to the top of node_modules as a side effect of some other package wanting it), and my code had been quietly relying on it for months.
That's a phantom dependency. It's a package your code can import even though you never declared it.
It works until it doesn't, and the moment it stops working is when some unrelated dep gets bumped and the chain that was carrying it disappears. That's usually right after deploy, when real traffic finally hits the path that needed it.
Here's the thing. The term “phantom dependency” isn't pnpm's.
It was coined by Pete Gonzalez and the team behind Microsoft's Rush, the monorepo build tool, who've been documenting why flat node_modules is broken since 2017.[4]
pnpm popularized the term in the rest of the JavaScript world, but the people who first wrote it down knew this was a bug a long time before pnpm did anything about it.
Summary
node_modules silently lets your code import packages you never declared. pnpm refuses. The bugs that surface during a switch were already in your code; npm was hiding them.Four package managers matter in 2026: npm (GitHub-owned, the default that ships with Node), pnpm (Zoltan Kochan's 2017 project, the one this whole article is about), Yarn 4 (Meta, mostly used by teams that set up a Yarn project years ago), and Bun (the runtime-plus-package-manager Anthropic acquired in December 2025).
npm dominates by inertia, and pnpm pulled about 1.29 billion downloads in the 30 days to November 17, 2026, up from just under 500 million in July.[11]
The case for pnpm in 2026 isn't that the daily install completes a few seconds faster.
It's that npm puts packages in node_modules that you didn't ask for, and the version of node_modules you're shipping to production silently disagrees with the one you're running locally. pnpm doesn't fix this by being clever. It fixes it by refusing to lie to you.
pnpm 12 and npm 12, side by side
Here's the whole comparison on one screen. Every row is from the two projects' own documentation or release notes, and the rows that moved this year are the ones that changed my advice.
| Feature | npm 12.2.3 | pnpm 12.21.0 |
|---|---|---|
| How you get it | Installed with Node.js[21] | Separate install, such as npm install -g pnpm[20] |
| Supported Node.js | 22.22.2 or later, 24.15.0 or later, and 26 or later[22] | 18, 20, 22, 24, and 26[20] |
| Default node_modules layout | Hoisted (flat)[16] | Isolated (symlinked)[2] |
| Content-addressable global store | No | Yes, hard-linked into projects[2] |
| Undeclared imports | Resolve by default; --install-strategy=linked catches them[16] | Fail by default |
| Dependency install scripts | Blocked unless allowScripts approves them (new in 12.0.0)[22] | Blocked unless listed in allowBuilds; strictDepBuilds fails the install[23] |
| Git and tarball dependencies | allow-git defaults to none[16] | blockExoticSubdeps on by default for transitive dependencies[23] |
| Wait before installing a new release | Off until you set min-release-age (in days)[16] | minimumReleaseAge defaults to 1440 minutes, 1 day[23] |
| Manages Node.js versions | No | Yes[24] |
| Lockfile | package-lock.json | pnpm-lock.yaml |
Takeaway
In November 2026 the gap that matters is layout. npm 12 now blocks dependency install scripts and git dependencies by default, but it still lets an undeclared import resolve, and it still installs a release the minute it is published.
What's actually different inside node_modules
Quick orientation for the cross-field reader: when you list a dependency in package.json, your package manager downloads it and all the things it depends on, recursively. Those deps of deps are called transitive dependencies. The whole graph lands in a folder called node_modules. The difference between npm and pnpm is the shape of that folder.
Here's the contrast at the directory level for a project that depends on Express:
# npm (flat / hoisted)
node_modules/
├── express/ ← your declared dep
├── accepts/ ← transitive, hoisted to top
├── body-parser/ ← transitive, hoisted to top
├── cookie/ ← transitive, hoisted to top
├── lodash.merge/ ← transitive, hoisted to top
└── ... (everything visible at top level)
# pnpm (symlinked / strict)
node_modules/
├── express -> .pnpm/express@4.18.2/node_modules/express
└── .pnpm/
├── express@4.18.2/node_modules/
│ ├── express/ ← real package files
│ ├── accepts -> ../../accepts@1.3.8/node_modules/accepts
│ └── ... (only what express declared)
├── accepts@1.3.8/node_modules/...
└── ... (each package gets only its declared deps)The mechanical difference is one decision. Both managers walk your package.json, resolve the full transitive graph, and copy or link files into node_modules. They do not agree on the shape.
npm hoists. Since version 3, every package in the resolved tree, including transitive deps, gets installed at the top of node_modules whenever it can.[3] Two transitive deps wanting the same version of react? react goes in once, at the top. The original justification was deduplication: hoist as much as possible to keep the tree shallow.
pnpm refuses to hoist by default. Each package gets exactly the deps it declared, no more. The layout is two layers:
- A content-addressable store, a global cache where every version of every package you've ever installed lives once, named by a hash of its contents. Default location is
~/Library/pnpm/storeon macOS,~/.local/share/pnpm/storeon Linux, and~/AppData/Local/pnpm/storeon Windows. Files are hard-linked into your project so they cost no additional disk space.[1] - A virtual store at
node_modules/.pnpm/. For each package version, a directory whose ownnode_modulescontains symlinks only to the deps that package actually declared. Then, at the top ofnode_modules, a single symlink per direct dep into the virtual store.[2]
The trick that makes this work is one Node.js detail: Node's module resolution ignores symlinks.[2] When react is required from inside next/dist/index.js, Node looks for it relative to the real file location, not the symlinked one.
So if next declared react as a peer dep, the symlink graph supplies it. If next didn't declare it, there is nothing at the right path, and the require fails.
What npm and pnpm put on disk
npm flattens. pnpm builds a graph that mirrors your package.json.
Same input
- package.jsonDeclares your direct deps
- Lockfilepackage-lock.json or pnpm-lock.yaml
- Transitive treeWhat your deps depend on
Two install strategies
Same input, different on-disk shape
Different output
- npm: flat node_modulesEvery package, including transitive deps, hoisted to the top whenever possible
- pnpm: CAS + symlink graphGlobal store of every package version. Symlinks compose the dep tree per package
The phantom-dep prevention is not pnpm being clever. It's pnpm refusing to put things on disk that your package.json didn't ask for.
Takeaway
npm's flat tree is what the rest of the JavaScript ecosystem assumes you have. pnpm's symlink graph is what your package.json actually says.
Phantom dependencies, in plain English
Here's the smallest version of the bug. A package whose code uses lodash.merge:
import merge from 'lodash.merge'
export function deepCopy<T>(a: T, b: Partial<T>): T {
return merge({}, a, b)
}{
"name": "app",
"dependencies": {
"express": "^4.18.0"
}
}The author never put lodash.merge in dependencies. But Express has a chain of transitive deps, and somewhere in that chain lodash.merge shows up. With npm, lodash.merge lands at node_modules/lodash.merge/ via hoisting. The TypeScript compiler finds it. Node finds it. Tests pass. Build ships.
Then six months later, Express bumps a transitive dep that no longer pulls lodash.merge. Or someone runs npm install on a clean machine and the resolution order shuffles. Or the deploy machine resolves a slightly different tree than the dev laptop. The lodash.merge directory disappears from the flat tree. The require fails. Production breaks.
With pnpm, the same code never works on day one. lodash.merge exists in the global store, but pnpm doesn't hoist it. There's no top-level symlink to it because your package.json didn't ask for one.
The tests fail immediately, with a clear “module not found” pointing at the real bug, which is that you need to add lodash.merge to package.json.
Receipt
@types/react as a dependency.[5] Under npm, @types/react was usually there anyway, hoisted in by some other package. Under pnpm without --shamefully-hoist, type-checking failed. The bug was on Radix's side, but flat hoisting hid it for years. Same story for Nuxt 3 in June 2022, with vue and ufo.[6] “Using pnpm without --shamefully-hoist is possible today but requires explicitly installing vue and ufo dependencies and we don't want this since Nuxt was always a zero-config package.”
Nuxt fixed it. So did Radix. Both bugs took maintainers' time, and both bugs had been in production for users running Nuxt or Radix on npm. Nobody noticed, because flat hoisting hid them.
I'll be straight about the evidence. There is no neat database of phantom-dep bugs you can quote percentages from. The bug class is invisible until it isn't, and most teams who hit it write a git commit message rather than a postmortem.
The postmortems that exist are mostly the ones where pnpm exposed something that had been broken for a long time. That's a survivorship problem with the published record, not a problem with the bug.
So here's the strong version of the claim. Most JavaScript projects with more than a handful of dependencies have at least one phantom dep right now and don't know it. The structure of the bug all but guarantees it.
Switching to pnpm is the cheapest audit you can run. If you're already running strict-mode TypeScript and treating every implicit-any as a real bug, dependency strictness is the matching upgrade.
npm 12 copied the safety defaults, not the layout
When I first wrote this piece in May, “pnpm is safer by default” was half the argument.
It isn't anymore. npm 12.0.0 shipped on July 8, 2026 with two breaking changes that matter here: dependency lifecycle scripts are blocked unless the root package's allowScripts policy allows them, and allow-git and allow-remote now default to none.[22] That is the same posture pnpm documents for its own defaults.[23]
The workflow is nearly identical, so here are the two next to each other. Install, read the list of skipped scripts, approve the ones you trust, rebuild.
npm install
npm install-scripts approve esbuild
npm rebuildpnpm install
pnpm approve-builds
pnpm rebuildpnpm's own feature-comparison page still marks build-script security as a pnpm-only feature.[24] That was true until July. It is a vendor page, and vendor pages lag the competitor's release notes by a few months.
What npm 12 did not copy is the layout, and the one-day wait: min-release-age is empty until you set it, where pnpm's minimumReleaseAge starts at 1440 minutes.[16] [23]
So the sentence I'd have written in May, “pnpm is the safe one,” is now “pnpm is the strict one.” Strict about what you import, and strict about how fresh a release has to be.
Speed and disk are real, but they're the cherry on top
The numbers are real. I'm just not telling you to switch because of them.
The speed comparison below is from pnpm's own benchmark page, refreshed on November 17, 2026.
It installs two real projects through the same registry over an emulated 200 Mbps link with 50 ms of latency, and each number is the fastest of the three most recent runs.[10] The heavy project is fourteen modern toolchains (Angular, Nest, Vite, webpack, Storybook) resolving to about a gigabyte.
npm 12.2.2
pnpm 12.21.0
- Fresh clone, nothing cached1m 44s14.4s
- CI install from a lockfile29.7s9.01s
- Reinstall with cache and lockfile20.5s2.60s
- Update one dependency14.8s2.32s
Takeaway
pnpm 12 won all six scenarios on this project, from 3x faster on the CI install to 174x when nothing had changed. The row you will feel most is the CI install, 29.7 seconds against 9.01, because it runs on every push.
Across a typical mix of twenty local installs, pnpm's page puts npm at 8 minutes 33 seconds and pnpm 12 at 1 minute 11 seconds, about 7x.[10] That is vendor-published, so the ratios are flattering.
The pnpm maintainers wrote the harness, and it runs on one machine. I haven't run my own benchmark suite. Run pnpm run benchmark from their repository and read your own numbers.
Disk space is the other speed-adjacent number, and I'm leaving it out on purpose. Every “70% less disk” claim in circulation traces back to pnpm's marketing. The mechanism, hard-linking from a single store, does dedupe. The actual savings depend on how many overlapping projects you have on the same drive.
One app: small. Thirty-package monorepo or heavy fresh-cloning: large. Run the numbers on your own setup. Don't take a vendor's word for it.
Speed and disk are good reasons to switch. They're poor reasons to lead a recommendation, because they're easy to dismiss. “I don't mind waiting twenty more seconds for an install” is a real position. “I don't mind shipping silent dependency bugs to production” isn't.
The lockfile war and the deploy I broke
There's a second way npm lies to you, and it shows up at deploy time, not install time. The repo this article is published on uses pnpm. You can tell because of one warning, in capital letters, in the project's CLAUDE.md:
Receipt
packageManager in package.json). Do not run npm install, it will create a package-lock.json that competes with pnpm-lock.yaml on Vercel and break the deploy.I wrote that warning after I broke the deploy. I'd been working in a different repo, came back here, ran npm install out of muscle memory, didn't notice the new package-lock.json, committed everything, pushed.
Vercel built. The build was green. The deploy went out. Some pages started rendering with subtly different React versions in different chunks. By the time I noticed, I'd been debugging hydration mismatches in the wrong place for an hour.
What happened is that Vercel's deploy build looks at your repo and detects the package manager from the lockfile.[12] When both pnpm-lock.yaml and package-lock.json exist, Vercel's documented detection order picks pnpm. Silently.
No warning, no error, no banner that says “you have two lockfiles, you might want to look at this.” pnpm built node_modules from pnpm-lock.yaml while my local dev had been using package-lock.json. Two different version trees from one repo. Both green. Different bugs in production than in dev.
The silent failure mode
How a mixed-lockfile bug surfaces
- Day 0, morning
You run npm install in a pnpm repo
package-lock.jsonappears next topnpm-lock.yaml. Both are committed. Locally, everything works because npm built yournode_modules. - Day 0, deploy
Vercel detects pnpm from the lockfile precedence order
Vercel installs from
pnpm-lock.yaml. Build passes. You see green. - Day 0, prod
node_modules in prod no longer matches dev
Different transitive resolutions. Subtle behavior changes that don't trip your tests, because your tests run against your local node_modules, which is the npm one.
- Day N
A real bug surfaces
Hydration mismatch, a missing peer dep at runtime, a version skew in a util library. The cause is invisible from logs because both versions of the dep "exist" in their respective trees.
Takeaway
The single-lockfile rule is more important than which lockfile you pick. Don't let two managers compete in the same repo.
If you're thinking “but Vercel has a packageManager field in package.json you can pin,” yes. Corepack, the bundled tool that reads that field and enforces which package manager actually runs, can wire it up.[13]
Except Node.js stopped shipping Corepack with the official distributions starting at v25, so that pin is now something you install and maintain yourself. The story got worse, not better, for any team that pinned through Corepack and forgot it.
The official Vercel mitigation is an environment variable called ENABLE_EXPERIMENTAL_COREPACK.[12] The word “experimental” is doing a lot of work in that name.
It's not just Vercel. Netlify, Cloudflare Pages, AWS Amplify, and GitHub Actions all do lockfile-presence detection. AWS Amplify has an open issue titled, plainly, “amplify always chooses the wrong package manager.”[17]
Next.js has a Vercel cache-poisoning bug from misdetected package-manager changes that users were still hitting in production months after it was first reported.[18] Install reliability is one of the silent axes on the developer-experience scorecard teams forget to grade themselves on.
The fix to my deploy bug was one git rm package-lock.json and a CLAUDE.md line warning future-me. The fix is cheap. The bug isn't.
The honest counter: where pnpm makes you bleed
I owe you the steelman. pnpm is the right default in 2026 for most teams. It is not the right default for all teams, and it gets in your way in three specific places.
Tools that assume flat node_modules. This is the meaningful pain. Bundlers and build tools written before pnpm's layout was widespread sometimes can't follow symlinks correctly. The pnpm config flag --shamefully-hoist exists for these cases.[7] It collapses pnpm's strict tree back into a flat one.
Zoltan Kochan shipped the flag in pull request #2006 in September 2019. The PR description, in full, is empty.[8]
Kochan added the editorial word “shamefully” to the flag name and shipped the escape hatch with no rationale text, which is the only honest framing of how he felt about being forced to ship it. Most people, he later wrote, “won't bother to search for the right pattern, they just hoist everything.”[9]
In 2024 to 2026, the tools that historically forced this flag (Webpack, Metro, certain Vaadin and Nx setups) mostly grew real symlink support.
But if your stack lands on something old that can't, you'll know: the install completes and your build fails with a module-resolution error. The fix is --shamefully-hoist, which gives you back the npm behavior, with all its phantom-dep downside. Treat that flag as a temporary patch, not a long-term setting.
Bun is real, and it's faster. Bun shipped isolated installs as the default for new workspace projects in version 1.3.2.[14]
The architecture is the same as pnpm's, a central store with symlinks, and Bun's installs are noticeably faster than pnpm's on real benchmarks. Bun also runs your code, which means in a Bun-only stack you trade a Node-plus-pnpm pair for one tool.
The catches: Bun still has a small compatibility tail that surfaces around native C++ addons and certain long-running Next.js scenarios, and Bun is now Anthropic-owned.
The single-vendor risk is real: a runtime that one company controls is one acquisition target, one strategic pivot, or one pricing decision away from being something other than what you signed up for. Node and pnpm don't carry that.
If you're greenfield, your dep set is mainstream JS/TS, and you can live with that risk, Bun is the better recommendation than pnpm. For everyone else, pnpm is the boring choice, and boring is what you want from the tool that resolves your dependencies.
Yarn Berry with nodeLinker pnpm. Yarn 4 ships with a configurable install strategy controlled by the nodeLinker setting. Setting it to pnpm produces “a node-modules [that] will be created using symlinks and hardlinks to a global content-addressable store”[15] with the same on-disk shape as pnpm and the same phantom-dep protection.
If your team is already on Yarn 4, switching to pnpm is busywork. The trickier question is the Yarn loyalist still running PnP (Plug'n'Play, Yarn's in-memory resolver that skips node_modules entirely).
PnP is stricter than pnpm, but every IDE, type-checker, and framework has to explicitly support it, and React Native still requires the node_modules fallback. PnP is the right call for teams whose tooling already plays nice with it, and a long road for everyone else. pnpm splits the difference.
npm's own --install-strategy=linked. npm can now build the same isolated layout as pnpm. Its 12.x documentation lists linked as an install strategy and recommends that package authors use it during development to catch undeclared dependencies before they publish.[16] The default is still hoisted, and nothing in that page suggests it will change.
In May I called this strategy experimental and dismissed it. That was out of date, and I'm glad to correct it. It is a fair way to test for phantom dependencies in a repo that has to stay on npm.
The argument for switching to pnpm is not that no other isolated-store package manager exists. Bun, Yarn 4 with nodeLinker: pnpm, and now npm with linked are real.
The argument is that pnpm is the most boring of the good options that make the strict layout the default, and the package manager is the one piece of your platform stack you should be most boring about.
Which one to pick
Here's the decision as a table. Find your row.
| Your situation | Pick | Why |
|---|---|---|
| New app or library you will maintain | pnpm | Undeclared imports fail on your laptop instead of in production |
| Monorepo | pnpm | The shared store pays off most across many overlapping packages (monorepo or polyrepo) |
| Throwaway script, or a machine where you can't install tools | npm | It is already there, and npm 12 blocks install scripts by default |
| Existing project that must stay on npm | npm with --install-strategy=linked | Catches phantom dependencies without changing tools |
| Greenfield, mainstream dependencies, one-vendor risk is fine | Bun | Isolated by default and faster, but single-vendor |
| Already on Yarn 4 | Stay, set nodeLinker: pnpm | Same on-disk shape, so switching is busywork |
What to do Monday morning
If you're convinced and on a fresh project, three commands:
# Install pnpm globally (Node no longer bundles Corepack as of v25)
npm install -g pnpm
# In your project, replace npm with pnpm
pnpm import # converts package-lock.json into pnpm-lock.yaml
rm package-lock.json
pnpm installCommit pnpm-lock.yaml, delete package-lock.json from version control, and add a CI check that fails the build if package-lock.json reappears.
If you're convinced and on an existing project, the migration path looks similar, but the first pnpm install will surface every phantom dep in your codebase as a build or runtime error.
That's the point. Each one is a real bug you've been carrying. Don't reach for --shamefully-hoist to make them go away. Add the missing entries to package.json and re-install.
Three things to watch for in the first week:
- A build-only or test-only tool that breaks because it can't follow symlinks. Either upgrade the tool, or set
--shamefully-hoistonly if there is no upgrade path. If you do, leave a comment with the upgrade-blocker so future-you remembers why. - Your CI cache. GitHub Actions' setup-node action defaults to npm/yarn detection. You'll need
cache: 'pnpm'on the action. - A teammate runs npm install once. They will. Add the warning. A pre-commit hook that fails when both lockfiles exist is two lines and a real defense.
Switch your next project. The first thing that breaks is the bug npm was carrying.
Sources and further reading
- 1.Primarypnpm motivation: content-addressable store, hard-links. pnpm.io
- 2.Primarypnpm's symlinked node_modules structure. pnpm.io
- 3.Primarynpm folders: hoisting since v3. docs.npmjs.com
- 4.PrimaryRush: phantom dependencies (term origin, Microsoft). rushjs.io
- 5.Reporting@radix-ui packages cause compiler errors due to phantom dependency on @types/react. GitHub, Jan 20, 2023
- 6.ReportingNuxt 3: phantom dependencies on vue and ufo (Pooya Parsa). GitHub, Jun 10, 2022
- 7.Primarypnpm settings: shamefully-hoist. pnpm.io
- 8.Primarypnpm PR #2006: rename shamefully-flatten to shamefully-hoist. Zoltan Kochan, Sep 10-11, 2019
- 9.PrimaryKochan on shamefully-hoist's history. pnpm GitHub Discussions, Jan 2024
- 10.Datapnpm benchmarks (auto-updated; data fetched November 17, 2026). pnpm.io. Vendor-published: npm 12.2.2 against pnpm 12.21.0
- 11.Datapnpm monthly downloads from the npm registry. api.npmjs.org
- 12.PrimaryVercel: package manager detection and precedence. vercel.com
- 13.PrimaryNode.js Corepack (no longer distributed with Node v25+). github.com/nodejs/corepack
- 14.PrimaryBun isolated installs (default since v1.3.2). bun.com
- 15.PrimaryYarn Berry config: nodeLinker. yarnpkg.com
- 16.Primarynpm 12 config: install-strategy, allow-git, min-release-age. docs.npmjs.com
- 17.ReportingAWS Amplify: amplify always chooses the wrong package manager. GitHub
- 18.ReportingNext.js: persistent build cache issue from package-manager misdetection. GitHub Discussions
- 19.Datanpm registry: latest tag for pnpm (12.21.0) and npm (12.2.3). registry.npmjs.org/pnpm/latest and registry.npmjs.org/npm/latest, read November 18, 2026
- 20.Primarypnpm installation: pnpm 12 and supported Node.js versions. pnpm.io
- 21.Primarynpm: about npm versions. docs.npmjs.com. npm is installed with Node.js.
- 22.Primarynpm CLI 12.0.0 release notes. July 8, 2026. Lifecycle scripts blocked by default, allow-git and allow-remote default to none, Node support range.
- 23.Primarypnpm: mitigating supply chain attacks. pnpm.io. allowBuilds, strictDepBuilds, blockExoticSubdeps, minimumReleaseAge.
- 24.Primarypnpm feature comparison with npm. pnpm.io. Vendor-published.
Frequently asked questions
- What is the difference between pnpm and npm?
- The difference is how they lay out node_modules. npm 12 hoists every package, including transitive dependencies, into one flat folder, so your code can import packages you never declared. pnpm 12 stores each package version once in a global content-addressable store and symlinks into each project only the dependencies that package declared, so an undeclared import fails instead of working by accident. npm ships with Node.js, and pnpm is a separate install.
- Is pnpm faster than npm?
- Yes. In pnpm's own November 17, 2026 benchmark, pnpm 12.21.0 beat npm 12.2.2 in all six install scenarios on both test projects. On a one-gigabyte project of 14 toolchains, a fresh clone took 1 minute 44 seconds with npm and 14.4 seconds with pnpm, and a CI-style install from a lockfile took 29.7 seconds against 9.01 seconds. The benchmark is vendor-published, so treat the exact ratios as flattering and run your own.
- Should I use pnpm or npm in 2026?
- Use pnpm for any app, library, or monorepo you will maintain, and keep npm for throwaway scripts or machines where you cannot install a second tool. pnpm gives you faster installs and a strict dependency tree, and the migration is one command, pnpm import. Bun is faster and also isolated, so it is a fair pick on a new project with mainstream dependencies, with the trade-off that Anthropic acquired Bun in December 2025.
- What is a phantom dependency in Node.js?
- A phantom dependency is a package your code can import even though you never listed it in package.json. npm hoists transitive dependencies to the top level of node_modules, which makes them importable by accident. The code works until an unrelated dependency bump removes the package that was pulling it in, and then it breaks, usually in production.
- Does npm 12 block install scripts like pnpm does?
- Yes. Since npm 12.0.0 on July 8, 2026, dependency install scripts are blocked unless the root package's allowScripts field approves them, and npm install-scripts approve records the approvals. pnpm has blocked dependency build scripts unless they are listed in allowBuilds, with strictDepBuilds failing the install otherwise. The remaining gap is that pnpm also waits one day before installing a new release by default, and npm's min-release-age is off until you set it.
- Can I have both package-lock.json and pnpm-lock.yaml in one repo?
- You can, and you should not. Deploy platforms pick a package manager based on which lockfiles are present, so the tree they build can differ from the one on your laptop. Both builds go green and the divergence only surfaces as a strange runtime bug. Commit exactly one lockfile and add a check that fails the build if a second one appears.
Written by
Tech Talk News Editorial
Computer engineering background. Writes about software, AI, markets, and real estate, and the places where the three meet.
More about the author