January 31, 2020
performance cache node npm pnpm packages modules managers yarn typescript benchmarks
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.
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.
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.
Well, yes, and some times even faster, check the benchmarks results below, performed on a standard React App:
There are more benchmark tests made with other different scenarios, you can find all tests below:
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.
453 words authored by Gen-AI! So please do not take it seriously, it's just for fun!