How to clear the npm cache on a Mac

2 MIN READ · UPDATED
SHORT ANSWER
npm cache clean --force

It only deletes downloaded packages. Your projects keep working; npm downloads what it needs on the next install.

1. Check how big it is

npm keeps its cache in a hidden folder in your home folder.

du -sh ~/.npm/_cacache

2. Clear it

npm asks for --force because the cache repairs itself and rarely needs clearing by hand.

npm cache clean --force

3. Check it worked

npm cache verify

Is it safe?

Yes. The cache only holds copies of packages from the registry. Nothing in your projects' node_modules changes.