Skip to content
BENIBIX Learn

npm vs pnpm

People think pnpm is just a faster npm, and there is more to it. npm puts a full copy of each package in every project. pnpm keeps one copy of each version on the disk and links each project to it. pnpm is also strict, so code may only use the packages it listed.

Development🛠️ Editors & Tools

npm

The tool for getting JavaScript packages. It is also the big shelf they come from.

npm is the package tool for JavaScript, and it comes with Node.js. It is also the name of the online registry where JavaScript packages are shared. It holds millions of packages, more than any other registry. The npm install command fetches packages. A file named package.json lists what a project needs. npm can also run a project's scripts, like npm test.

Example
Jack runs npm install in a new React project. A folder fills up with each package the app needs.
Why it matters
Most JavaScript projects are set up and run through npm. That goes for the browser and the server.
Full entry
Development🛠️ Editors & Tools

pnpm

A tool that adds packages to JavaScript apps. It keeps one copy of each on your disk.

pnpm is a free package manager for JavaScript that saves disk space. It keeps each version of a package only once, in one store on your computer. Each project then links to the files in that store. It does not copy them. So ten projects that use the same package share one copy. It installs from the same npm registry as npm and Yarn.

Example
Jack has 20 small projects that all use React. With pnpm, React sits on his disk once, and every project points to it.
Why it matters
Big projects pull in thousands of packages. Sharing one copy saves gigabytes and makes installs quicker.
Full entry

In one line

npm
The tool for getting JavaScript packages. It is also the big shelf they come from.
pnpm
A tool that adds packages to JavaScript apps. It keeps one copy of each on your disk.