Folder

Is the npm cache (~/.npm/_cacache) safe to delete on a Mac?

Yes, the npm cache is safe to delete: npm's own docs say clearing it is never necessary except to reclaim disk space, and packages download again on the next install.

2 safe1 careful1 never

updated read 3 minfor npm 10 and 11 on macOS

The short answer

  1. 01

    Safe to delete. ~/.npm/_cacache is npm's download cache. Your projects and node_modules folders do not depend on it.

  2. 02

    npm writes it on every npm install, npm ci and npx run, and never removes data by itself.

  3. 03

    You lose download time: the next install fetches packages from the registry again, and offline installs fail until it refills.

  4. 04

    The command: npm cache clean --force. Use npm cache verify to garbage-collect without wiping.

See its real size on your Mac. Hoardless measures this folder and previews the delete.Download free trial

What is the ~/.npm/_cacache folder?

~/.npm/_cacache is npm's package cache. npm's documentation says the cache root is ~/.npm on macOS and other POSIX systems, and that cache data lives in a subfolder named _cacache.

Inside are package tarballs and registry metadata, stored by content hash, so folder names mean nothing to a person. It is shared by every project on your Mac. None of it is your code.

What writes it and why does it grow?

npm writes to it on every install. npm install, npm ci and npx store each package they download, so the next install of the same version can skip the network.

  • No automatic pruning: npm's docs state that npm will not remove data by itself, and the cache grows as new packages are installed.
  • Every version stays: each upgrade adds the new version beside the old ones.
  • Many projects, one cache: each project's dependencies add to the same folder, including projects you deleted long ago.

A custom location set with npm config set cache moves the whole cache. npm config get cache prints the active root.

How big does the npm cache get?

It depends on how many packages and versions you have installed over time, so there is no normal size. Measure your own:

du -sh ~/.npm/_cacache

Prints the cache size. Removes nothing.

du -sh ~/.npm/*

Shows _cacache next to the other folders in the cache root, such as _logs (npm's debug logs) and the folder npx installs packages into, usually _npx.

Is it safe to delete the npm cache?

npm's docs say the cache is self-healing and that it should never be necessary to clear it for any reason other than reclaiming disk space.

WhatVerdictWhat you lose
~/.npm/_cacacheSafeCached downloads. The next install fetches them again.
The npx folder (usually ~/.npm/_npx)SafePackages npx ran; npx installs them again next time.
Clearing right before working offlineCarefulInstalls fail without a network until the cache refills.
~/.npmrcNeverYour npm settings and any registry login tokens. It is a config file, not cache.

How do I clear the npm cache?

Use npm's own command first:

npm cache verify

Garbage-collects data npm no longer needs and checks the index. Keeps everything that is still valid.

npm cache clean --force

Deletes every entry in the cache. npm refuses to run clean without --force.

The manual way: close any running npm commands, then drag ~/.npm/_cacache to the Trash. npm creates the folder again on the next install.

What Hoardless does: its Node detector lists ~/.npm/_cacache at the Auto tier and runs npm cache clean --force, using the npm your login shell finds. When npm is not installed, it moves the folder to the Trash instead, at the same tier, and logs the move in the undo log.

What comes back and when?

Only the packages you install again. The next npm install or npm ci downloads each dependency and stores it in the cache. Versions you never install again stay gone.

The first install after clearing is slower because every package comes from the registry. For the other half of Node disk use, see node_modules and the guide to npm, pnpm, Yarn and Bun caches.

See every package cache in one list

Hoardless sizes the npm cache (Auto tier, npm cache clean --force), the Yarn cache (Auto) and the pnpm store (Auto, pnpm store prune), and previews the plan before anything runs. Without the tool, npm and Yarn caches go to the Trash with an undo log.

14-day full trial. macOS 14 or later.

Questions

Why does npm cache clean need --force?

npm made clean require --force because the cache is self-healing and clearing it is rarely needed. The flag confirms you mean it.

Does clearing the npm cache delete node_modules?

No. node_modules lives inside each project. The cache is a separate store of downloaded tarballs and metadata under ~/.npm/_cacache.

What else is in ~/.npm?

npm writes debug logs to _logs inside the cache, and npx installs the packages it runs into a folder in the cache, usually _npx. Run ls ~/.npm to see them. Both are rebuilt on use.

How do I find where my npm cache is?

Run npm config get cache. It prints the cache root, which is ~/.npm unless you changed the cache setting.