Mac folder guide
What Is ~/.npm on Mac? Is It Safe to Delete?
~/.npm
~/.npm is npm’s cache: every package tarball npm has downloaded, plus logs. It is safe to clear. npm downloads packages again the next time you install.
What is ~/.npm on a Mac?
npm keeps a content cache so it doesn’t download the same package version twice. Over years of projects it can grow to several gigabytes.
It is separate from node_modules. Clearing it doesn’t break existing projects, it only means the next install downloads more.
What’s inside
- _cacache, the package cache itself
- _logs, debug logs from past npm runs
- _npx, packages fetched by npx
How to clear ~/.npm safely
- Check the size with the first command below.
- Run npm cache verify to clean up and check the cache without clearing it.
- To remove it all, run npm cache clean with the force flag.
du -sh ~/.npm
npm cache verify
npm cache clean --force
When to keep it
- Nothing essential, but clear it when you have a connection, since installs need to download again.
Related guides
Questions people ask
Is it safe to delete the .npm folder?+
Yes. It is a cache. npm downloads packages again when it needs them.
Does clearing the npm cache delete node_modules?+
No. node_modules folders in your projects are separate and stay as they are.
Why does npm want the force flag?+
npm treats its cache as self-healing and asks you to confirm a full clear. npm cache verify is the gentler option.
See which folders fill your Mac
MacZentra, a disk analyzer and storage cleaner for Mac, scans your disk locally and draws it as a Treemap or Sunburst, so a folder like this one shows up with its real size. Scanning and every visualization are free. Cleaning is a one-time $49.99 purchase, and anything you remove goes to the Trash, so it can be restored.
macOS 13 Ventura or later · Apple silicon