Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

npx

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?

like image 343
Flimm Avatar asked Aug 20 '20 17:08

Flimm


People also ask

How do I force clear npm cache?

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.

Does NPX cache packages?

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.

Is it safe to clean npm cache?

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.

How do I clear the command line cache?

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.


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.

like image 144
fregante Avatar answered Sep 17 '22 15:09

fregante


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
like image 31
James L Avatar answered Sep 20 '22 15:09

James L