PNPM popularity is growing rapidly, is it time to ditch npm & yarn? published 1/31/2020 | 2 min read

We've been using npm to manage node modules for years, until Yarn came and started to gain huge popularity. Although Yarn version 2 (released days ago) introduces many performance improvements, rewritten in TypeScript, and more, but still neither NPM nor Yarn address a very important issue, which is disk space usage, this is specifically where pnpm comes in.



pnpm · Fast, disk space efficient package manager
Fast, disk space efficient package manager
Yarn
Fast, reliable, and secure dependency management.

Welcome to a new devspedia story, we'll briefly discuss pnpm, a Node package manager similar to NPM & Yarn, but with one great benefit, which is greatly reducing disk space consumed by node modules across all your different projects.



How it works?

pnpm saves disk space by simply downloading the packages of your project into a common place on your computer, and then it adds hard links inside your node_modules directory.

So imagine you have 100 projects, each of them is using lodash@1.0.0, with npm and yarn, this means you'll have 100 copies of this specific version of lodash.

However, with pnpm, you'll always have only 1 copy, which will save you plenty disk space.

Is it fast as yarn?

Well, yes, and some times even faster, check the benchmarks results below, performed on a standard React App:

pnpm out-performs yarn and npm in almost every test

There are more benchmark tests made with other different scenarios, you can find all tests below:

pnpm/benchmarks-of-javascript-package-managers
Benchmarks of JavaScript Package Managers. Contribute to pnpm/benchmarks-of-javascript-package-managers development by creating an account on GitHub.

Hope you enjoyed today's story, maybe give pnpm a try?

Thanks for reading devspedia, I love you, and I'll see you the next time.



You may also like reading: