PNPM Rocks

For years, I was a NPM loyalist. As the default package manager for Node.js, npm is ubiquitous - we all have it installed already, so why bother with anything else?

But earlier this year, I finally made the switch to pnpm after one too many headaches with npm. Here's why pnpm won me over:

Faster Installs

The big selling point for me was how much faster pnpm is compared to npm. Initial installs are quicker, but more importantly, reinstalls on subsequent machines are blazing fast.

With npm, reinstalling dependencies, especially on monorepos with multiple packages, could take ages. pnpm uses a content-addressed file storage approach, so it only needs to fetch packages once.

Better Lockfile Management

pnpm uses a YAML lockfile instead of JSON. Not only is it easier to read and diff in commits, but it's less likely to cause merge conflicts. I've frequently seen npm package-lock.json conflicts grind development to a halt.

The pnpm-lock.yaml is nicely structured and handles simultaneous installations across branches and merge orders gracefully.

Easier Monorepo Management

For monorepos and multi-package projects, pnpm makes dependency management smoother. The hoisting of dependencies helps reduce duplication. Simultaneous installation of different packages in different branches just works.

Overall, pnpm feels purpose-built for monorepo and multi-package repository workflows.

Smaller Node Modules Folder

With npm, it's not uncommon for the node_modules folder to balloon to gigabytes in size, especially on projects with lots of dependencies. The content addressing in pnpm eliminates duplication of files across packages. No more black hole sucking up all your disk space!

Other Nice Touches

pnpm has other handy features like workspace support, recursively flattening nested node_modules, and a clean CLI interface. The pnpm website lists additional motivations for its approach.

Conclusion

For serious Node.js developers working across multiple projects, pnpm speeds up your workflow, reduces headaches, and makes monorepo management enjoyable. The improvements to install speed, lockfiles, and disk usage add up to a superior developer experience.

If you do much Node.js development, I encourage you to give pnpm a try. It's what finally allowed me to break up with npm for good!