SiftMac
Is it safe to delete? · Package caches · Updated 21 November 2026

Is it safe to delete ~/.npm, npm’s cache?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. What’s inside ~/.npm
  2. Where npm keeps it
  3. How big it gets
  4. Clearing it the npm way
  5. What happens after you clear it
  6. Other npm folders worth knowing
  7. Questions

1. What’s inside ~/.npm

npm keeps a copy of every package tarball and registry answer it fetches, so installing the same version again can skip the download. Entries are stored by a hash of their contents and checked against that hash on the way in and on the way out. A damaged entry is fetched again instead of breaking an install, which is why npm calls its cache self-healing.

npm’s documentation is plain about growth: npm will not remove data by itself, and the cache grows as new packages are installed. Every version of every dependency from every project you’ve installed is in there until something clears it.

2. Where npm keeps it

~/.npm

That’s the default on a Mac, set by npm’s cache setting. If you or a tool changed it, npm will tell you where it is:

npm config get cache

The folder is hidden in Finder. Press ⇧⌘G and paste the path, or press ⇧⌘. in your home folder to show hidden items.

3. How big it gets

There’s no size limit, so the number reflects how many projects you’ve installed and how often their dependencies changed since the folder was last cleared. To see the total and which part holds it:

du -sh ~/.npm
du -sh ~/.npm/_cacache ~/.npm/_npx ~/.npm/_logs

4. Clearing it the npm way

  1. Let any npm install that’s running finish.
  2. For a trim, run npm cache verify. It checks the cache, garbage-collects data nothing points to any more, and reports what it removed. Sometimes that’s enough.
  3. To empty it, run npm cache clean --force. npm asks for --force on purpose: its docs say clearing should never be needed for any reason other than getting disk space back.
npm cache verify
npm cache clean --force

The _npx folder can go as well; npx downloads a tool again the next time you run it. With npm not running:

rm -rf ~/.npm/_npx/*

Leave ~/.npmrc alone. It’s a separate file in your home folder with your npm settings and any registry tokens you’ve logged in with.

5. What happens after you clear it

6. Other npm folders worth knowing

Global packages from npm install -g aren’t in ~/.npm; they live under npm’s prefix, which npm prefix -g prints. Each project’s packages are in its own [node_modules](/safe-to-delete/node-modules), the other place to look in projects you’ve finished with. Other package managers keep separate caches: Yarn, pnpm and Bun.

Questions

Why does npm cache clean ask for --force?

Clearing is made deliberate because it doesn’t fix anything: npm verifies every cached file when it reads it and refetches damaged ones. The docs name disk space as the only good reason, so add --force when that’s what you want.

Will clearing the npm cache break my projects?

No. Nothing you run reads from ~/.npm. Only installs use it, and an install downloads whatever is missing.

Does npm ever clean its cache automatically?

No, the folder only grows. npm cache verify comes closest to a trim: it drops data the cache index no longer points to and keeps the rest.

What is the _npx folder?

Packages npx fetched to run one-off commands. They’re safe to delete; the next npx run of that tool downloads it again.

How SiftMac handles it. SiftMac doesn’t empty ~/.npm itself. Its space map shows how big the folder is and labels it as npm’s cache: packages npm downloaded before, which come back when a project needs them. npm cache clean --force does the clearing. Under Developer files, SiftMac lists node_modules in projects you haven’t changed for months.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works