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

Is it safe to delete? · Package caches · Updated 21 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes.** `~/.npm` only holds copies of packages npm has already downloaded, plus logs and tools fetched by `npx`. Your projects, their `node_modules` and your global packages aren’t in it.
- **What it costs you:** the next install of each package downloads it again, so that install needs the network and takes longer.
- **Does it come back?** Yes. npm adds to it with every install and never removes anything on its own.
- SiftMac’s verdict: Rebuilds

## 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.

- `_cacache`: the cache proper, with downloaded tarballs and package metadata. This is the big part.
- `_npx`: packages that `npx` (or `npm exec`) downloaded to run a command no project of yours has installed, like a project generator you ran once.
- `_logs`: debug logs from recent npm runs.

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

- Your projects keep working. Code runs from each project’s own `node_modules`, never from the cache.
- The next `npm install` or `npm ci` downloads each package from the registry again. The first install after clearing is the slow one; the cache fills as it goes.
- Versions don’t change: `package-lock.json` decides what gets installed, not the cache.
- An install with `--offline` fails for anything not cached yet, so clear it while you’re online.

## 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`](https://siftmac.com/safe-to-delete/node-modules), the other place to look in projects you’ve finished with. Other package managers keep separate caches: [Yarn](https://siftmac.com/safe-to-delete/yarn-cache), [pnpm](https://siftmac.com/safe-to-delete/pnpm-store) and [Bun](https://siftmac.com/safe-to-delete/bun-cache).

## 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: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [npm Docs: npm cache](https://docs.npmjs.com/cli/v11/commands/npm-cache)
- [npm Docs: config, the cache setting](https://docs.npmjs.com/cli/v11/using-npm/config#cache)
- [npm Docs: npm exec (npx)](https://docs.npmjs.com/cli/v11/commands/npm-exec)

## Related

- [Is it safe to delete node_modules?](https://siftmac.com/safe-to-delete/node-modules)
- [Is it safe to delete Yarn’s cache?](https://siftmac.com/safe-to-delete/yarn-cache)
- [Is it safe to delete pnpm’s store?](https://siftmac.com/safe-to-delete/pnpm-store)
- [Is it safe to delete Bun’s install cache?](https://siftmac.com/safe-to-delete/bun-cache)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)

Canonical: https://siftmac.com/safe-to-delete/npm-cache
