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

Safe~/.npm

Yes. ~/.npm is npm's download cache and npx store, and npm refills it as needed. How to measure it, clear it with npm's own command, and what to keep.

Updated 16 November 2026 · 3 min read

Verdict: Safe. ~/.npm is npm's cache of downloaded packages, plus the tools npx has run and npm's logs, so you can clear it and npm downloads anything it needs again. Use npm cache clean --force for the main cache rather than deleting folders by hand.

What lives in ~/.npm

npm's cache documentation gives ~/.npm as the default cache location on macOS and Linux. On the macOS 15.5 Mac we checked this on, it came to 448 MB, split like this:

  • _cacache (338 MB): the main cache. npm describes it as a content-addressable cache that stores all HTTP request data and other package-related data, so installs can reuse packages instead of downloading them again.
  • _npx (73 MB): packages downloaded by npx and npm exec to run one-off commands.
  • _prebuilds (37 MB) and _logs, smaller folders. _logs holds the debug logs npm writes when commands run.

Your projects are not in here. Each project's packages live in its own node_modules folder.

What happens if you delete it

  • Rebuilds by itself: everything. The next npm install or npm ci downloads packages from the registry and refills the cache. The next npx command downloads its tool again.
  • Costs a little time: installs are slower until the cache is warm again, and you need a network connection.
  • Lost for good: nothing you made. Your npm settings and registry login tokens are in ~/.npmrc, a separate file in your home folder, as npm's npmrc documentation explains. Global packages live under npm's global prefix, not here.

The one case to think about is working offline. If you rely on the cache to install without a network, keep it until you are back online.

How to check its size safely

In Terminal, run:

du -sh ~/.npm/* 2>/dev/null | sort -h

This lists each part of the cache with its size, biggest last. It only reads. To confirm where your cache is, in case it has been moved:

npm config get cache

This prints the path and changes nothing.

In Finder, ~/.npm is hidden because its name starts with a dot. Choose Go > Go to Folder, paste ~/.npm and press Return, then select a folder and choose File > Get Info. Press Command-Shift-Full Stop (.) to show hidden files in a Finder window.

The safest way to get the space back

  1. Finish or stop any npm install that is running.

  2. Clear the main cache with npm's own command:

    npm cache clean --force
    

    Warning: this deletes npm's download cache for good. It does not touch your projects, settings or global packages, and npm fills the cache again as you install.

  3. If you would rather keep the cache and just tidy it, run npm cache verify. npm's documentation says it garbage-collects data the cache no longer needs and checks the rest.

  4. For npx tools, list what is stored and remove entries you no longer use:

    npm cache npx ls
    

    Then use npm cache npx rm with the entry you want to remove.

  5. Check the result with du -sh ~/.npm.

If you prefer Finder, open ~/.npm, move _cacache or _npx to the Bin and empty it. macOS 14 Sonoma and later also include a trash command, such as trash ~/.npm/_npx, which moves a folder to the Bin rather than deleting it.

What never to touch

  • ~/.npmrc. It sits next to ~/.npm in your home folder and holds your settings and login tokens. It is not part of the cache.
  • The cache while an install is running. Wait for it to finish.
  • A custom cache folder you have not checked. If npm config get cache prints somewhere unexpected, make sure that folder is only used by npm before you clear it.

Clearing the cache does not shrink your projects. For that, see is it safe to delete node_modules, and for other package managers, the Yarn cache. Our guide to clearing cache on a Mac covers pip, Homebrew and app caches too.

How Headroom helps

Headroom's Clean scan lists the npm download cache in ~/.npm/_cacache under Developer caches, with the note "npm downloads packages again when it needs them." It also lists npx tools not used for seven days or more as "Old npx tools". Both are ticked and deleted for good when you clean. Your settings in ~/.npmrc and npm's logs are left alone. The scan is free, and the $19 one-time licence clears what you tick. See the cleaner or download Headroom.

Questions

Will deleting ~/.npm break my projects?

No. Projects use their own node_modules folders, which are not inside ~/.npm. The next install simply downloads packages again instead of reading them from the cache.

Why does npm cache clean need --force?

npm's documentation describes the cache as self-healing and resistant to corruption, so clearing it should only be needed to get disk space back. Requiring --force makes sure you mean it.

Does deleting ~/.npm remove my npm login?

No. npm keeps your settings and registry tokens in ~/.npmrc in your home folder, a separate file from the ~/.npm cache folder.

What is the _npx folder inside ~/.npm?

It is where npx, or npm exec, keeps the packages it downloads to run commands. You can list and remove entries with npm cache npx ls and npm cache npx rm.