Can I delete the .npm folder on my Mac? Yes, it's safe

Yes, it's safe to deleteDiskmack safety tier: Safe to clean
~/.npm

Yes, you can delete the ~/.npm folder. It's npm's package cache: compressed copies of every package you've ever installed, kept only so reinstalls can skip the download. Your projects, global tools, and npm login all live elsewhere and are not affected. The only cost is that your next npm install pulls packages from the network instead of from disk.

What it is

~/.npm is the cache npm keeps in your home folder (the ~ is shorthand for /Users/yourname). The bulk of it sits in a subfolder called _cacache, short for content-addressable cache. Every time you run npm install, npm stores a compressed copy of each package it downloads there, so a future install of the same version can be copied from disk instead of fetched from the registry. There's also a _logs subfolder holding debug logs from past npm runs.

The folder grows because it never forgets. A package you installed once for a tutorial three years ago is still in there, alongside every version bump of every dependency of every project since. It belongs to npm itself rather than to any one project, which is why it lives in your home folder instead of next to your code. On a Mac that sees regular JavaScript work it often reaches several gigabytes, and 10 GB or more isn't unusual if you've been installing packages for years without ever clearing it.

Is it safe to delete?

Yes, safely. Nothing in ~/.npm is needed for your projects to run. Installed dependencies live in each project's own node_modules folder, globally installed CLI tools live under your Node installation, and your npm login token lives in a separate file, ~/.npmrc. The cache exists purely to make reinstalls faster, so deleting it costs you exactly one thing: the next npm install in each project re-downloads packages instead of copying them locally.

npm itself treats the cache as disposable. Since npm 5 it verifies and repairs itself automatically, and the maintainers are confident enough about that to make you pass a --force flag before the CLI will clear it. Diskmack flags ~/.npm automatically and clears it using npm's own cleaner rather than raw deletion. Either way, there is no scenario where clearing this folder loses work you can't get back.

How to check its size

In Finder: In Finder, choose Go > Go to Folder (or press Command-Shift-G), type ~/.npm and press Return. Finder opens the folder; press Command-Up Arrow to jump to your home folder with .npm selected, then Command-I to see its size.

In Terminal:

du -sh ~/.npm

How to clean it

  1. Close anything that might be mid-install: Terminal windows running npm, and editors with build tasks going.
  2. In Finder, choose Go > Go to Folder (Command-Shift-G), type ~/.npm and press Return.
  3. Press Command-Up Arrow. Finder jumps to your home folder with the .npm folder selected.
  4. Press Command-Delete to move it to the Trash.
  5. Empty the Trash to actually reclaim the space.

The official way: this tool ships its own cleanup command, which handles locks and indexes correctly.

npm cache clean --force

The --force flag is required. npm considers the cache self-healing and wants you to be deliberate about wiping it, but the command is safe to run. If an install happens to be running while you clear the cache, that one install may error; just run it again.

Will it come back?

Yes, immediately and by design. The next time you run npm install in any project, npm re-downloads what that project uses and files a copy back into ~/.npm. How fast it regrows depends entirely on how much JavaScript work you do: someone installing packages daily will see gigabytes return within weeks, while a casual user might not notice growth for months. If it's back to gigabytes a month after you clear it, that's not a bug, that's just how much JavaScript you install.

Common questions

Will deleting ~/.npm break my projects?

No. Each project's installed dependencies live in its own node_modules folder, which the cache wipe doesn't touch. The worst case is that your next npm install runs slower while packages re-download from the registry.

Is ~/.npm the same thing as node_modules?

No. node_modules sits inside a project and holds the packages that project actually runs on. ~/.npm is a shared download cache in your home folder that installs pull from. You can delete the cache without touching any node_modules folder, and vice versa.

Why does npm cache clean need --force?

Since npm 5 the cache checks and repairs its own integrity, so the maintainers consider manual clearing unnecessary in normal use. The flag is a speed bump to make sure you mean it, not a warning that the operation is risky.

Will I be logged out of npm afterward?

No. Your auth token is stored in ~/.npmrc, a small config file that has nothing to do with the cache. Publishing and installing private packages keep working after the wipe.

Related folders