JavaScript

How to clear the global npx cache

Advertisements

I have been using npx a lot lately, especially whenever I want to use a CLI tool. It is an excellent alternative to installing packages globally since it installs them in a temporary cache instead.

Even though it is installed in a temporary location, I figured it is a good idea to clear the cache once in a while. To do so, we can run the following command on a Mac:

rm -rf ~/.npm/_npx
Bash

And if we were on a Windows machine:

del /q /s %LocalAppData%/npm-cache/_npx
Bash

If npx cache is not located at one of these locations and we want to find the exact location for it, we can also use the following command to do so.

npm config get cache
Bash

And that is it. The command will clear the global npx cache and we can then install a new version if we want to do so or just have a clean slate to begin with. If you have any questions, do let us know in the comments below.

Saransh Kataria

Born in Delhi, India, Saransh Kataria is the brain behind Wisdom Geek. Currently, Saransh is a software developer at a reputed firm in Austin, and he likes playing with new technologies to explore different possibilities. He holds an engineering degree in Computer Science. He also shares his passion for sharing knowledge as the community lead at Facebook Developer Circle Delhi, NCR which is a developer community in Delhi, India.

Share
Published by
Saransh Kataria

Recent Posts

Remapping keyboard keys to avoid Carpal Tunnel

I am terrible at optimizing my keyboard layout for anything. But off lately, my little…

4 weeks ago

Fixing cookies are blocked for a website with shields down on Brave

I recently switched completely to the Brave browser and have set ad blocking to aggressive…

5 months ago

Generating a QR code using Node.js

I was preparing a slide deck for a hackathon and decided to put in a…

6 months ago

Copy/Pasting output from the terminal

Manually copy-pasting the output of a terminal command with a mouse/trackpad feels tedious. It is…

7 months ago

How To Get The Hash of A File In Node.js

While working on a project, I wanted to do an integrity check of a file…

8 months ago

Native popover API in HTML

Popovers have been a problem that was typically solved by using a third-party solution. But…

8 months ago
Advertisements