How to clear the pnpm store

pnpm keeps one shared store and hard-links packages into each node_modules, so it usually uses far less space than npm. The store still only grows until you prune it.

These commands permanently delete files. Most are caches the tool rebuilds on its own (the next build or install is slower and may need internet). Anything that can hold data you cannot re-download is flagged on the page. Read each command, then copy and run it yourself. devdisk never runs cleanup commands for you.

Where the store is

Any OS
pnpm store path

Projects on a different drive get their own store (a .pnpm-store folder at that drive’s root), because hard links cannot cross drives.

Check its size

macOS / Linux
du -sh "$(pnpm store path)"
Windows (PowerShell)
"{0:N1} GB" -f ((Get-ChildItem (pnpm store path) -Recurse -File | Measure-Object Length -Sum).Sum / 1GB)

Prune unreferenced packages

Any OS
pnpm store prune

Removes packages that no project on this machine references anymore. pnpm calls this harmless; the only cost is that a future install may download a package again. Don’t run it in the middle of an install.

Why deleting node_modules did not free space

Files in node_modules are hard links to the store. Deleting a project’s node_modules removes one link; the data stays in the store until pnpm store prune. The reverse is also true: deleting the store folder frees little while projects still link to it. Delete old node_modules first, then prune.

Measure with devdisk

devdisk is a free, read-only scanner. It lists the pnpm store under Safe to regenerate with pnpm store prune as the suggested command, and counts hard-linked files once so sizes are not double-counted. It never deletes anything; it only shows sizes and writes a cleanup script you read and run yourself.

macOS / Linux
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
Windows (PowerShell)
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py

Run free scannerSample report

Want one-click cleanup?

A planned devdisk desktop app for Mac and Windows: live treemap, cleanup that moves files to the Trash, scheduled scans. One email when it launches, with an early-supporter price. Your address is used only for that, and every email has an unsubscribe link.

FAQ

Will pnpm store prune break my projects?

No. It only removes packages no project references. Projects you still have keep working.

Can I just delete the store folder?

Yes, but every project then needs pnpm install with network, and space only comes back once old node_modules are gone too.

Is pnpm store prune the same as pnpm cache?

No. The store holds package files. pnpm also keeps a small metadata cache; the store is where the gigabytes are.

More cleanup guides