Talk to the NOC, IST hours — +91 75994 50220 support@bigdomainhost.com
Guide

pnpm vs npm: what really differs, and which one to use

npm ships with Node.js. pnpm promises less disk use and stricter installs. This guide explains the real differences without benchmark hype, maps the commands side by side, and shows how to move a project across.

Short answer: npm vs pnpm comes down to storage and strictness. npm copies every dependency into each project's flat node_modules. pnpm stores each package version once in a content-addressable store and links it into projects, so it uses less disk, is usually faster on repeat installs, and blocks imports of packages you did not declare. Commands are similar: pnpm add instead of npm install for adding a package, and pnpm dlx instead of npx.

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 workspaces array in the root package.json and links those folders during npm install. You target one with the --workspace flag.
  • pnpm reads a pnpm-workspace.yaml file with a packages list. It adds the workspace: protocol for pinning a dependency to a local package, --filter for selecting projects, and pnpm -r for 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

Tasknpmpnpm
Install everything in package.jsonnpm installpnpm install
Add a dependencynpm install expresspnpm add express
Add a dev dependencynpm install -D vitestpnpm add -D vitest
Remove a dependencynpm uninstall expresspnpm remove express
Run a scriptnpm run buildpnpm run build or pnpm build
Run a binary from the projectnpx jestpnpm exec jest
Run a package without installing itnpx create-vue my-apppnpm dlx create-vue my-app (also pnx)
Clean install for CInpm cipnpm install --frozen-lockfile or pnpm ci
Install a global toolnpm install -g pm2pnpm 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

  1. Commit your work so you can go back.
  2. Install pnpm.
  3. If the repository uses workspaces, declare them in pnpm-workspace.yaml first.
  4. Run pnpm import. It generates pnpm-lock.yaml from package-lock.json, npm-shrinkwrap.json or yarn.lock, preferring the versions already locked.
  5. Delete node_modules, then run pnpm install.
  6. Run the build and the tests. Add any missing packages that surface as "Cannot find module" errors.
  7. Delete package-lock.json, and replace npm commands in your scripts, CI configuration, Dockerfile and README.
  8. 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 with nodeLinker set to hoisted, 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 )

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.

Host your Node.js app on a VPS Ask an engineer on WhatsApp

Answers

Frequently asked questions

Still unsure? Call +91 75994 50220 or write to support@bigdomainhost.com — a human replies in IST hours.

What is pnpm?

pnpm is a package manager for JavaScript projects and an alternative to npm. The name stands for performant npm. It uses the same registry and package.json, but keeps every package version once in a shared store and links it into each project instead of copying it.

Is pnpm better than npm?

It depends on your situation. pnpm uses less disk space when you have many projects, is usually faster on repeat installs and stops code from importing undeclared packages. npm needs no extra installation and is what most tutorials and platforms assume. For a single small project the difference is minor.

Can I use pnpm and npm in the same project?

You should pick one per project. Each tool has its own lockfile, package-lock.json for npm and pnpm-lock.yaml for pnpm, and neither reads the other's file during a normal install. Keeping both leads to team members installing different versions.

How do I switch from npm to pnpm?

Install pnpm, then run pnpm import in the project to generate pnpm-lock.yaml from your existing package-lock.json. Delete node_modules, run pnpm install, and test the build. Finally remove package-lock.json and update your scripts and CI to call pnpm.

What is the pnpm equivalent of npx and npm ci?

For npx, use pnpm dlx to run a package without installing it, or pnpm exec to run a binary that is already in the project. For npm ci, use pnpm install --frozen-lockfile. Current pnpm documentation also lists the shorter pnx and pnpm ci commands.

pnpm vs Yarn: what is the difference?

Yarn Classic installs a flat node_modules much like npm. Modern Yarn defaults to Plug'n'Play, which removes node_modules and uses a loader file instead. pnpm keeps a node_modules folder but builds it from links into a shared store, which keeps it compatible with most Node.js tooling.

Support that picks up the phone.

In IST hours, in Hindi or English, and WhatsApp replies fastest at any time. Sales, migration and emergencies all reach the same engineers. No offshore queue, no 48-hour first reply.

Need cPanel or WHM with the ports already sorted?

Web & cPanel hosting comes with cPanel ready to log in to, reseller hosting adds white-label WHM, and a KVM VPS can have cPanel & WHM pre-installed. Call +91 75994 50220 or email support@bigdomainhost.com.