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.
Where the store is
pnpm store path
- macOS:
~/Library/pnpm/store - Linux:
~/.local/share/pnpm/store(or$XDG_DATA_HOME/pnpm/store) - Windows:
%LOCALAPPDATA%\pnpm\store
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
du -sh "$(pnpm store path)"
"{0:N1} GB" -f ((Get-ChildItem (pnpm store path) -Recurse -File | Measure-Object Length -Sum).Sum / 1GB)Prune unreferenced packages
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.
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py
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.