What is the pnpm store, and is it safe to delete?

The pnpm store is the shared folder where pnpm keeps one copy of each package version, linked into every project, and pnpm store prune removes the copies no project uses.

Shiva ChandraMaker of Clean House · · 2 min read
Short answer

The pnpm store is a shared folder where pnpm keeps a single copy of each package version, which projects link to instead of copying. Run pnpm store prune to remove packages no project uses. That is safe, and anything removed downloads again if needed. Avoid deleting the store by hand.

Path
~/Library/pnpm/store
What it is
A shared, content-addressable store of every package pnpm has installed
Typical size
Several gigabytes on Macs with many projects, though it saves space compared with separate node_modules
Made by
pnpm
Safe to delete?
Safe to clear
Comes back?
Yes, packages are re-downloaded when a project needs them

What is in this folder?

Instead of copying packages into each project, pnpm keeps them in one store and links them into node_modules. That is why a pnpm project folder can look small while the store grows. The store is shared across all projects on a drive.

Run pnpm store path to see where it is. On macOS a common location is ~/Library/pnpm/store, and some setups use ~/.pnpm-store.

Is it safe to delete?

Yes, with the right command. The pnpm documentation says pnpm store prune removes unreferenced packages, and anything removed is fetched again if a later install needs it. It is the safe way, because it only removes what no project uses.

Deleting the store by hand is riskier. Your projects' node_modules are linked into it, so removing the whole folder can leave those projects broken until you run pnpm install again.

How do I clear it by hand?

  1. Stop any running install.
  2. Prune the store.
  3. If a project reports missing files afterward, run pnpm install in it.
pnpm store path
pnpm store prune
Prefer pnpm store prune over rm -rf on the store, which can break linked projects.

How do I stop it growing?

Prune after deleting old projects. Packages used only by those projects become unreferenced and are then removed.

How Clean House handles it

Clean House recognizes the pnpm store as shared JavaScript packages made by pnpm and marks them as coming back. It leaves the store alone while pnpm is running. If you remove it in Clean House, the files go to the Trash and Recently Cleared can put them back.

Questions

Is it safe to delete the pnpm store?

Pruning is safe. Deleting the whole folder by hand can break projects linked to it until you run pnpm install again.

How do I clean the pnpm store?

Run pnpm store prune. It removes packages that no project uses.

Where is the pnpm store?

Run pnpm store path to see it. A common location on a Mac is ~/Library/pnpm/store.

Sources

  1. pnpm Docs: pnpm store