How can I clear the central cache for `npx`?

Viewed 16296

Let's say you're running this command:

npx gulp

npx will search for gulp within node_modules/.bin, and if it doesn't find it there, it will use a central cache. If it is missing, npx will install it.

How do I clear the central cache to force npx to reinstall gulp in this case?

2 Answers

On macOS (and likely Linux) it's ~/.npm/_npx, you can drop it with:

rm -rf ~/.npm/_npx

On Windows it should be %LocalAppData%/npm-cache/_npx


Either way, you can find npm’s cache by running npm config get cache and then finding an npx folder in there.

I needed to do this, due to an error in create-react-app saying 'We no longer support global installation of Create React App.' despite there being no global install. It was stuck in the npx cache, and I removed it like this

npx clear-npx-cache
Related