Is it safe to delete pnpm’s store?
- Yes, by pruning it.
pnpm store pruneremoves packages no project on your Mac still uses, and pnpm’s docs call it harmless. Deleting the whole store by hand gains little and can bite. - What it costs you: a pruned package downloads again if a project asks for it later.
- Does it come back? The store refills with every
pnpm install, so prune it now and then. - SiftMac’s verdict: Rebuilds
1. How pnpm’s store works
pnpm doesn’t give each project its own downloaded copy of each package. It keeps one content-addressable store per disk, where every file is stored once, and fills each project’s node_modules from it. How it fills them depends on the disk:
- On a Mac, the default
packageImportMethod,auto, tries clones first. APFS supports copy-on-write clones, so a file innode_modulesand the one in the store share their blocks until one of them is changed. - Where cloning isn’t possible, pnpm falls back to hard links, two names for one file, and only then to plain copies.
Either way, a package used by twenty projects takes its space once. The flip side is that the store keeps every version your projects have moved through until something prunes it.
pnpm also keeps a smaller cache in ~/Library/Caches/pnpm: package metadata from the registry, pnpm dlx downloads and some install checks.
2. Where it is
~/Library/pnpm/store
~/Library/Caches/pnpm
Those are the macOS defaults; pnpm store path prints the store in use. Keep projects on an external drive and pnpm makes another store on that drive, because links and clones only work within one disk.
3. How big it is, and what that number means
du -sh "$(pnpm store path)" ~/Library/Caches/pnpm
Read that number with care. du adds up every file it finds and can’t see that a file in the store and its clone in a project share blocks. Removing a package from the store frees its space only when no project still holds a clone or hard link of it. While some project’s node_modules shares those blocks, they stay in use.
4. How to clear it
- Let any
pnpm installthat’s running finish. - Run
pnpm store prune. It removes unreferenced packages, those not used by any project on the system. pnpm’s docs say it has no side effects on your projects and suggest running it occasionally, not constantly. - If you like, empty the metadata cache too. It refills on the next install.
pnpm store prune
rm -rf ~/Library/Caches/pnpm/*
Don’t move the store in Finder or delete it while projects still use it. A project set up with pnpm’s global virtual store, which is off by default, keeps only links into the store and stops working until it’s installed again.
5. What you’ll notice afterwards
- Nothing in your projects: each
node_moduleskeeps its own clones or links of every file. - An install that needs a pruned package downloads it again, and
pnpm-lock.yamlkeeps its version the same. - The first install after emptying
~/Library/Caches/pnpmfetches package metadata again, so it’s a little slower. - Space comes back only for packages nothing shares any more; projects you keep hold on to theirs.
Questions
Why didn’t deleting node_modules in a pnpm project free much space?
The files there are clones, or hard links, of files in the store. Their blocks stay in use by the store until pnpm store prune removes packages no project references.
Can I move pnpm’s store to an external drive?
Only together with your projects. pnpm wants the store on the same disk as the projects it serves; otherwise it copies packages instead of linking them, which uses more space, not less.
How often should I run pnpm store prune?
Now and then, for example after deleting old projects. pnpm recommends it occasionally but not too often, since anything pruned has to be downloaded again when a project wants it.
What is ~/Library/Caches/pnpm?
pnpm’s cache of package metadata, pnpm dlx downloads and some install checks. It’s safe to empty and refills as you install.
How SiftMac handles it. SiftMac clears pnpm’s metadata cache in ~/Library/Caches/pnpm with its App caches (verdict Rebuilds), and leaves the store in ~/Library/pnpm to pnpm store prune, which knows what projects still use. When it lists an old pnpm project’s node_modules under Developer files, the size shown counts only blocks the folder doesn’t share with the store, so you see what deleting really frees.
Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works