Diskzyv0.1
Safe to delete

What is the npm cache (~/.npm) on Mac? Is it safe to delete?

Short answer

Yes, the npm cache is safe to delete. It is a local copy of packages npm has already downloaded, and npm fetches anything missing from the registry the next time you install.

Where it is

~/.npm/_cacache

What it is

Every time npm installs a package, it saves the downloaded archive and its metadata in ~/.npm/_cacache. Later installs of the same version, in any project, can then come from disk instead of the network.

The cache only ever grows. npm does not remove old versions, so every release of every package you have installed stays there.

The ~/.npm folder also holds logs and the packages that npx has run. They are small by comparison, and they are also safe to remove.

How big it gets

Often a few GB after a year or two of regular JavaScript work.

How to clear it by hand

  1. Open Terminal.
  2. Run the command below. It deletes everything in npm's cache folder. npm asks for --force because it considers the cache self-healing and clearing it rarely necessary.
  3. If you only want npm to check the cache and drop unneeded data, run npm cache verify instead.
In Terminal
npm cache clean --force

What happens afterwards

Your projects and their node_modules folders keep working. The next installs download packages from the registry again, so they take longer and need a network connection.

How Diskzy handles it

Diskzy lists the npm cache in the Clean up tab and ticks it, along with the other package-manager caches it treats the same way.

Related guides

See where your Mac's space went

Diskzy maps your disk, explains System Data and clears what's safe. Free for 72 hours, then $9 once for 2 Macs.

Try Diskzy for free
Read this in:EnglishEspañolDeutschPortuguêsFrançaisTürkçe日本語