npm vs pnpm in short
npm is the package manager that comes with Node.js, and it copies every dependency into each project's node_modules folder. pnpm is a separate package manager that keeps one copy of every package version in a shared store on your disk and links it into each project, which saves space and usually makes installs faster. pnpm is also stricter by default: your code can only import packages that are listed in package.json.
Both use the same registry, the same package.json and the same packages. The differences are in how files are laid out on disk, how strict the layout is, and the command names.
What is npm?
npm is the default package manager for Node.js and is installed along with it. You already have it if node -v works. It installs packages into node_modules, records exact versions in package-lock.json, and runs scripts from package.json. Nearly every tutorial, CI template and hosting document assumes npm, which is its biggest practical advantage.
What is pnpm?
pnpm stands for "performant npm". It is a drop-in alternative that reads the same package.json and talks to the same registry, but stores and links packages differently. Its installation page describes pnpm 12, the current release line in November 2026, as a native executable that does not need Node.js once it is installed.
How they store packages: flat copies vs a shared store
npm: a hoisted, flat node_modules
npm's default install strategy is called hoisted. Packages that are not duplicated are placed at the top level of node_modules, and duplicates are nested where needed. Every project gets its own full copy. Ten projects that use the same version of a library hold ten copies of it on disk.
pnpm: a content-addressable store with links
pnpm saves every file of every package once, in a content-addressable store. When you install, the files are hard-linked (or cloned, on filesystems that support copy-on-write) from the store into the project. A hard link is a second name for the same data on disk, so it takes no extra space. If a new version of a package changes one file out of a hundred, only that one file is added to the store.
Inside the project, the real package folders live under node_modules/.pnpm. Only your direct dependencies appear at the top of node_modules, as symbolic links into that folder:
node_modules
├── express -> ./.pnpm/express@5.1.0/node_modules/express
└── .pnpm
├── express@5.1.0
│ └── node_modules
│ ├── express/ (files linked from the store)
│ └── qs -> ../../qs@6.14.0/node_modules/qs
└── qs@6.14.0
└── node_modules
└── qs/ (files linked from the store)
The version numbers above are only an illustration. One limit to know: the store should sit on the same drive and filesystem as your projects. Across drives, pnpm has to copy files instead of linking them, and the space saving is lost.
Disk use and install speed
We are not going to quote benchmark numbers, because they depend on the project, the machine, the network and whether caches are warm. The mechanisms are what matter:
- Disk. With npm, disk use grows with every project. With pnpm it grows with the number of distinct package versions on the machine. The more projects you keep, the bigger the gap.
- Repeat installs. When a package is already in the store, pnpm links it instead of downloading and unpacking it again. npm also has a download cache, but it still writes a full copy into each project.
- First install on an empty machine. Both have to download everything, so the difference is smaller. This is the usual situation on a fresh CI runner with no cache.
If disk space is the reason you are reading this, our guide to clearing the npm cache covers how to reclaim it with npm.
Strictness and phantom dependencies
A phantom dependency is a package your code imports even though it is not in your package.json. It works by accident, because some other package depends on it and npm's hoisting placed it at the top of node_modules. The day that other package drops or updates the dependency, your build breaks without any change on your side.
pnpm's layout prevents this in your own code. Only declared dependencies are linked at the top level, so an undeclared import fails straight away. This is also the most common surprise when migrating: an import that "always worked" now throws "Cannot find module". The fix is to add the package properly with pnpm add.
Two details keep this honest. pnpm is lenient towards third-party packages: by default it hoists all dependencies into a hidden node_modules/.pnpm/node_modules folder, so badly declared libraries still work, and you can switch that off by setting hoist to false. And npm can produce an isolated layout as well, with --install-strategy=linked, which its docs recommend to package authors for catching phantom dependencies. It is simply not the default.
Lockfiles: package-lock.json vs pnpm-lock.yaml
npm writes package-lock.json, which describes the exact dependency tree so that teammates, deployments and CI install the same thing. pnpm writes pnpm-lock.yaml for the same purpose. The two formats are not interchangeable, and each tool ignores the other's file.
Commit exactly one lockfile. A repository that contains both will drift, because each developer updates only the file their tool understands.
Workspaces and monorepos
Both tools can manage several packages in one repository.
- npm reads a
workspacesarray in the rootpackage.jsonand links those folders duringnpm install. You target one with the--workspaceflag. - pnpm reads a
pnpm-workspace.yamlfile with apackageslist. It adds theworkspace:protocol for pinning a dependency to a local package,--filterfor selecting projects, andpnpm -rfor running a command in every project.
In a large monorepo, the shared store and the strict layout are the main reasons teams pick pnpm.
Command comparison
| Task | npm | pnpm |
|---|---|---|
Install everything in package.json | npm install | pnpm install |
| Add a dependency | npm install express | pnpm add express |
| Add a dev dependency | npm install -D vitest | pnpm add -D vitest |
| Remove a dependency | npm uninstall express | pnpm remove express |
| Run a script | npm run build | pnpm run build or pnpm build |
| Run a binary from the project | npx jest | pnpm exec jest |
| Run a package without installing it | npx create-vue my-app | pnpm dlx create-vue my-app (also pnx) |
| Clean install for CI | npm ci | pnpm install --frozen-lockfile or pnpm ci |
| Install a global tool | npm install -g pm2 | pnpm add -g pm2 |
Notes on the table: pnpm does not install a package without saving it to package.json, which is why adding uses pnpm add. In a CI environment pnpm install already behaves as if --frozen-lockfile were set whenever a lockfile is present. The current pnpm documentation lists pnx as the main name for pnpm dlx, and a pnpm ci command. If your installed version does not have them, the longer forms in the table do the same job.
How to install pnpm
These are the methods on pnpm's installation page as of November 2026. With npm, which needs Node.js 18 or newer:
npm install -g pnpm@latest
pnpm --version
The same page also offers a standalone install script for Linux, macOS and Windows that does not need Node.js at all. On Windows, pnpm's own docs currently recommend the npm method, because Windows Defender sometimes blocks the standalone executable. To update later, run pnpm self-update. On a Bigdomainhost KVM VPS you have full root access, so either install method works on the server.
What about Corepack? Older tutorials tell you to run corepack enable. Corepack was distributed with Node.js from 14.19.0 up to, but not including, Node.js 25, so on newer Node.js versions it is no longer bundled. pnpm's installation page no longer lists it, and its CI guide advises against using it. Prefer the methods above.
How to migrate from npm to pnpm
- Commit your work so you can go back.
- Install pnpm.
- If the repository uses workspaces, declare them in
pnpm-workspace.yamlfirst. - Run
pnpm import. It generatespnpm-lock.yamlfrompackage-lock.json,npm-shrinkwrap.jsonoryarn.lock, preferring the versions already locked. - Delete
node_modules, then runpnpm install. - Run the build and the tests. Add any missing packages that surface as "Cannot find module" errors.
- Delete
package-lock.json, and replacenpmcommands in your scripts, CI configuration, Dockerfile and README. - Commit
pnpm-lock.yaml.
pnpm's docs note that the import is not a one-to-one conversion, so read the resulting diff and test before merging.
When to stay with npm
- You have one or two small projects, and disk space and install time do not bother you.
- Your deployment platform, build template or company tooling only supports npm.
- A tool in your stack does not cope with symlinked
node_modules. pnpm can imitate npm's layout withnodeLinkerset tohoisted, but then you lose the strictness. - You teach or onboard beginners, and matching every tutorial matters more than speed.
Switching is cheap to try and easy to reverse, as long as you keep the old lockfile in Git history.
A short note on Yarn and Bun
Yarn Classic (1.x) hoists packages into a flat node_modules, much like npm. Modern Yarn defaults to Plug'n'Play, which replaces node_modules with a single loader file, and can be switched to a node_modules or pnpm-style layout. So "pnpm vs Yarn" depends on which Yarn you mean. Bun is a separate runtime with its own package manager: bun install works in an existing Node.js project, writes a bun.lock file, and by default does not run the lifecycle scripts of installed dependencies.
Node.js projects on Bigdomainhost
Bigdomainhost's shared cPanel plans are built for PHP sites and WordPress, so Node.js applications belong on a KVM VPS, where full root access lets you install Node.js with npm, pnpm or both. Servers are in Mumbai and Delhi NCR, with an Ubuntu 24.04 image available, and the current price is on the pricing page. For sizing, see how much RAM a VPS needs. Support is on WhatsApp at +91 75994 50220 at any time and by phone in IST business hours.
Sources (checked )
- pnpm: Motivation
- pnpm: Symlinked node_modules structure
- pnpm: Installation
- pnpm: pnpm import
- npm Docs: npm install (CLI v11), install-strategy
- Node.js: Corepack README
How Bigdomainhost can help
When your Node.js project is ready to go live, a Bigdomainhost KVM VPS gives you full root access to install Node.js with npm, pnpm or both, NVMe storage and reserved RAM, on servers in Mumbai or Delhi NCR close to users in India. A Linux server is usually ready in under 60 seconds and is billed in 30-day prepaid periods from a rupee wallet, with the same price at renewal. Questions about sizing or deploying? Our engineers answer WhatsApp at any time.