30

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?

Flimm
  • 115,689
  • 38
  • 227
  • 240

2 Answers2

40

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.

PitaJ
  • 7,029
  • 6
  • 29
  • 51
fregante
  • 25,786
  • 14
  • 106
  • 143
  • 1
    Why is NPX keeping around outdated versions of packages that you need to explicitly purge? Doesn't seem right – ChrisM Mar 28 '22 at 17:50
19

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
James L
  • 15,726
  • 10
  • 49
  • 70