npm cache clean: How to clear npm cache on Mac
It’s safe to clear npm cache on a Mac with npm cache clean: the cache holds copies of every package npm has downloaded and only speeds up installs. On a Mac used for a few years of JavaScript work it often takes several gigabytes, while your projects and their node_modules stay when you clear it. This guide shows how to check the cache, clear it, and what to do with the Yarn and pnpm caches and old node_modules folders.

- Open MacWashing and choose System Junk in the sidebar.
- Click Start Scan.
- Look through what it found and click Clean. Anything debatable stays unchecked.
Free trial · macOS 14 or later
What the npm cache is
npm stores a copy of every package it downloads in ~/.npm/_cacache, so the next install of the same version doesn’t download it again. npm checks the cache itself and deletes damaged entries automatically, so it never needs clearing to fix installs. The only reason to clear it is to get the space back.
Check the cache with npm cache verify
This command deletes data the cache no longer needs and checks that the rest is intact. It frees some space and keeps the packages you use:
npm cache verify
How to clear npm cache with npm cache clean --force
This command deletes the whole npm cache. npm asks for --force because clearing is never needed to fix problems, only to reclaim disk space:
npm cache clean --forceInstalled packages, global tools and projects stay. The next install downloads packages again, so it takes longer and needs the internet.
Clear the Yarn and pnpm caches
Yarn 1 (Classic) keeps a global cache. This shows where:
yarn cache dirThis command clears it:
yarn cache cleanIn Yarn 2 and later, run this in a project folder to delete both the shared cache and the project’s cache:
yarn cache clean --allIf the project keeps its cache in Git (Zero-Installs), use this command instead. It deletes only the shared cache:
yarn cache clean --mirrorpnpm keeps one store for all projects. This command deletes the packages no project on the Mac uses anymore. It doesn’t affect your projects:
pnpm store pruneOld node_modules folders
Each project has its own node_modules, and together they often take more space than the cache. Delete node_modules in projects you don’t work on now: npm creates it again from package.json and package-lock.json at the next install when you return.

With MacWashing, it’s one click

System Junk in MacWashing clears the npm cache together with the caches of your other apps and tools. It also lists the node_modules folders of projects untouched for 90 days, unchecked, so you decide which to remove.
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 npm cache clean --force?
Yes. The cache holds copies of packages that npm can download again. Despite the word «force», nothing outside the cache is deleted.
Will clearing the npm cache break my projects?
No. Projects use the packages in their own node_modules. Only the next install of each package is slower, because npm downloads it again.
Why does the npm cache grow back?
npm adds every package version it downloads and doesn’t remove old ones. Check it from time to time: npm cache verify Or clear the cache when you need the space.