Moving to `pnpm`

February 5, 2025

I’m a little late to the pnpm party. Okay, a lot late. But hey, I finally made the leap! Here why i moved from npm and you should if you haven't already (no judgment 😜).

But first, What is a Package Manager?

Package manager helps you:

  1. Download and install packages (dependencies).
  2. Resolve and manage versions.
  3. Link dependencies efficiently.
  4. Run scripts and tools defined in your project (via package.json).

How dependencies are stored?

Featurenpmpnpm
Storage ModelFlat node_modules structureHard links from a global store
Disk UsageDuplicates packages per projectShares packages globally across projects
SpeedSlower for large depsMuch faster (due to caching + linking)
DeterminismImproved with npm v9+Highly deterministic out of the box
Installation TimeSlowerFaster (parallel + efficient linking)

Switching from npm to pnpm in an Existing Project

  1. Install pnpm globally:
npm install -g pnpm
  1. Remove node_modules and lockfile from your existing repositoiry:
rm -rf node_modules package-lock.json
  1. Install dependencies using pnpm:
   pnpm install
  1. update your engines field in package.json:
"engines": {
  "node": ">=22.20.0",
  "pnpm": ">=10.18.0"
}

Why Use pnpm Over npm?

Get in touch

Do you have an Exciting project for me? Send an E-mail. Or want to have a general conversation? Feel Free to send a message on Twitter.

Drop an e-mail

iamkanhuc@gmail.com

Find me on