pnpm store prune: how to clear pnpm cache on Mac

Clearing pnpm cache on a Mac with pnpm store prune is not like clearing npm’s: pnpm keeps each package once, in a shared store your projects link to, and the cleanup removes only packages no project needs anymore. Your projects are not affected, and if one needs a removed package later, pnpm downloads it again. This guide also explains where the store is and what to do with store folders of older pnpm versions.

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned
  1. Open MacWashing and choose System Junk in the sidebar.
  2. Click Start Scan.
  3. Look through what it found and click Clean. Anything debatable stays unchecked.

Free trial · macOS 14 or later

Where pnpm keeps packages

pnpm keeps each package version once, in its store, and links the files into every project’s node_modules with hard links. That’s why pnpm projects take less space than with npm. On a Mac the store is in ~/Library/pnpm/store, and this command shows the folder in use:

pnpm store path
Terminal: pnpm store path prints the store folder in use

pnpm also has a smaller cache in ~/Library/Caches/pnpm: package information, the cache of pnpm dlx and some install checks.

How to clear pnpm cache with pnpm store prune

This command deletes the packages no project uses and shows how much it removed. pnpm’s documentation says it’s not harmful and has no side effects on your projects:

pnpm store prune
Terminal: pnpm store prune reports how many packages it removed

Don’t run it too often. If you switch a project to a branch with older dependencies, pnpm has to download them again, and the install is slower.

Store folders of older pnpm versions

Inside ~/Library/pnpm/store each store format has its own folder, like v3, v10 or v11. pnpm store path shows the one your pnpm uses, and pnpm store prune cleans only that one.

  1. In Finder, choose Go › Go to Folder (Shift-Command-G), type ~/Library/pnpm/store and press Return.
The Go to Folder panel with ~/Library/pnpm/store typed
  1. Compare the folders with the last part of the pnpm store path output.
  2. Move the folders of older versions to the Trash if no project of yours still uses an older pnpm.
Finder, the pnpm store folder: the context menu of the older v3 store with «Move to Trash»

Don’t delete the folder pnpm uses now. Its files are hard-linked into your projects, so you get back far less space than Finder shows, and the next install in every project downloads all packages again.

What stays after pruning

  • Your projects, their node_modules and pnpm-lock.yaml.
  • Every package a project on the Mac still uses.
  • pnpm itself and its settings.

npm and Yarn keep their own caches: see how to clear npm cache and how to clear Yarn cache.

With MacWashing, it’s one click

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

System Junk in MacWashing finds the pnpm cache by name under App Caches, next to the npm, Yarn and other developer tool caches, and clears it together with the caches of your other apps.

Free trial · macOS 14 or later

Questions and answers

Will MacWashing delete my own files when it cleans?

No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.

What about apps that are open?

If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.

Is it free?

Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.

Is it safe to run pnpm store prune?

Yes. It removes only packages no project uses. If a project needs one of them later, pnpm downloads it again.

Does deleting a project free the space of its packages?

Not right away. Its packages stay in the store until you run pnpm store prune. Run it after removing old projects or their node_modules.

Where is the pnpm cache on a Mac?

The packages are in ~/Library/pnpm/store, and the smaller cache of package information is in ~/Library/Caches/pnpm. pnpm store path shows the store in use.