npm vs. yarn vs. pnpm
yarn has taken the hearts of millions of developers by storm since the release of it a few years ago. It installed packages magnitudes faster than npm could, had a lockfile that guaranteed consistency across machines and all kinds of nifty mechanisms to avoid corruption or downloading broken packages. It also brought the concept of workspaces to developers which made working with mono-repos less of a pain.
But yarn itself isn’t without issues, it’s not uncommon to need to clear the cache every now and then because some integrity checks start to fail or having to reinstall it altogether when installed through some package manager like brew. Those are minor nuances but can become annoying as they keep repeating.
If you pull in 10 dependencies via npm or yarn and all of them rely on the same lodash version you will end up with 10 copies of lodash in your node_modules folder. With pnpm you will end up with a single copy of lodash because the symlink of the first installation will let pnpm know that the lodash version that is needed has already been installed.
These days npm and yarn have pretty much the same performance and consistency with their lockfiles which means there is no real reason to use yarn unless you rely on the workspace feature. yarn 2 is currently under development which will bring a lot of improvements which should put it once again ahead of npm so make sure to check that out.
If you aren’t required by your work to use npm or yarn I would recommend to give pnpm a shot and see how it works out for you. It’ll definitly save you some time and disk space.