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?
Run: “npm cache clean –force” are both not working and you still can't clear the cache, you can force clear the cache by running: npm cache clean --force or npm cache clean -f . This will force delete the npm cache on your computer.
When you run a package using NPX, it searches for the package in the local and global registry, and then it runs the package. If the package is not already installed, NPX downloads the package files and installs the package, but it will only cache the files instead of saving it.
clean: Delete all data out of the cache folder. Note that this is typically unnecessary, as npm's cache is self-healing and resistant to data corruption issues.
Type CMD in the Search bar > right-click on Command Prompt and select Run as Administrator option. On Command Prompt window, type ipconfig /flushdns and press the Enter key. Once the Command is processed, you will see 'Successfully flushed the DNS Resolver Cache' message.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With