The npx cache on a Mac: why ~/.npm/_npx grows to gigabytes

Where npx keeps the packages it runs, why the same tool ends up there three times, why npm cache clean doesn't touch it, and how to clear it.

Short answer

npx installs every package it runs into ~/.npm/_npx, one folder per command you typed, and never removes them. npm cache clean --force doesn't touch that folder. On npm 11, npm cache npx ls lists the entries and npm cache npx rm removes them. On older npm, delete ~/.npm/_npx while nothing is running. Nothing you installed in a project depends on it.

How big it gets

I measured mine on 1 November 2026:

Terminal
$ du -sh ~/.npm/_cacache ~/.npm/_npx
#  11M  ~/.npm/_cacache
# 3.9G  ~/.npm/_npx

npm's own download cache was 11 MB. The npx folder next to it was 3.9 GB, 59 folders, from a few months of npx something in tutorials and READMEs. The biggest ones:

Folder holdsSizeFolder date
vercel 65.8364 MB30 Oct
vercel 62.1346 MB2 Oct
next 16.4337 MB28 Oct
netlify-cli 27.16276 MB30 Oct
vercel 59.1236 MB1 Jun
wrangler (three copies)652 MBAug to Oct
react-doctor 0.7.7 (twice)330 MB14 Jul

Deploy CLIs are the heavy ones. They pull in hundreds of dependencies, and npx keeps all of them.

Why the same tool is there three times

npx names each folder after a hash of the exact package text you typed. In npm's source (libnpmexec), it's the first 16 characters of a SHA-512 of the package names, sorted and joined. You can check it yourself:

Terminal
$ printf '%s' vercel | shasum -a 512 | cut -c1-16
# 69f9afb961c37556
$ printf '%s' vercel@latest | shasum -a 512 | cut -c1-16
# 67eb4586ca667318

Both folders were in my _npx. npx vercel and npx vercel@latest run the same tool, but npx sees different text, so each gets its own full install. A third spelling, from a README that pinned a version, made the third copy. The same goes for react-doctor and react-doctor@latest, which left me two identical 165 MB installs.

Nothing removes the old ones. My npx vercel folder still held vercel 59.1, last touched on 1 June.

npm cache clean doesn't reach it

npm cache clean --force is the usual advice, and it only removes _cacache. In npm's source the command deletes join(npm.cache, '_cacache') and nothing else. On my Mac it would have freed 11 MB and left the 3.9 GB.

Clear it

On npm 11 and later, npm manages the folder itself. These were on npm 11.12.1:

Terminal
$ npm cache npx ls                    # every entry, with its packages
$ npm cache npx info 69f9afb961c37556 # one entry in detail
$ npm cache npx rm 69f9afb961c37556   # remove one
$ npm cache npx rm                    # remove them all

ls printed (unknown) for 24 of my 59 entries, ones that don't record what was asked for. npm cache npx info <key> still shows the packages inside.

On npm 10, npm cache npx fails with EUSAGE (my npm 10.9.8 did). Delete the folder instead:

Terminal
$ npm --version
$ rm -rf ~/.npm/_npx
Safe

Nothing outside _npx uses those folders. Your projects keep their own node_modules, and global installs (npm install -g) live elsewhere. The only cost is that the next npx of each tool downloads it again.

Check first

Don't remove it while an npx command is running, such as a dev server or an MCP server started with npx. Quit those first. Many AI tool setups start MCP servers this way, so check before you clear.

Keep it small

  • Install the tools you use every day. npm install -g vercel keeps one copy, which npm update -g keeps current. npx is for tools you run once.
  • Type the name the same way every time. Pick npx vercel or npx vercel@latest, not both.
  • Clear it every few months. It only fills up again with what you actually use.

Browsers that npx downloads

Some tools you run with npx download more than packages. npx playwright install puts browsers in ~/Library/Caches/ms-playwright, outside _npx, and clearing npx leaves them. Mine held Chromium, Firefox and WebKit, 1.1 GB.

Shedi clears npm's download cache and the browsers Playwright and Puppeteer downloadedIt shows each one with its size and what brings it back, and moves what you pick to the Trash. It doesn't list the _npx folder yet, so use the commands above for that.
Get Shedi

To see every developer cache on your Mac side by side, _npx included, run diskreceipt, a free Terminal tool that only reads. For the rest of the JavaScript caches, see Delete node_modules safely.

Sources

  • npm docs: npm cache
  • npm docs: npm exec and npx
  • npm's source on this Mac: lib/commands/cache.js (clean deletes _cacache only) and libnpmexec/lib/index.js (the folder hash).
  • Measured on this Mac on 1 November 2026 (npm 10.9.8 and 11.12.1): du, npm cache npx ls, npm cache npx info and the hash check above. Nothing was deleted.

Questions

Where is the npx cache on a Mac?

In ~/.npm/_npx, inside npm's cache folder (npm config get cache prints it). Each folder there is one npx install, named after a hash of the package names you typed.

Does npm cache clean --force clear the npx cache?

No. npm cache clean removes only ~/.npm/_cacache, npm's download cache. The packages npx installed stay in ~/.npm/_npx. Use npm cache npx rm on npm 11, or delete the _npx folder.

Is it safe to delete ~/.npm/_npx?

Yes, as long as no npx command is running. The next npx run downloads what it needs again. The cost is that first run being slower.

Why does npx keep several copies of the same package?

npx names each folder after a hash of the exact text you asked for. npx vercel and npx vercel@latest are different text, so they get different folders, even for the same package.

How do I clear the npx cache?

On npm 11, run npm cache npx ls to see the entries and npm cache npx rm to remove them all, or npm cache npx rm <key> for one. On older npm, run rm -rf ~/.npm/_npx.