How to clear global npx cache

Published on May 30, 2023

1 min read

TOOLS

Recently, I've seen myself running into the following message whenever I'm using a certain CLI tool with npx.

1A new version of "x-package" is available
2You can update by running: npm install -g x-package

I don't want to install the CLI tool globally and go into the rabbit hole of maintaining it as a dependency.

One way I've found that works on macOS to clear the global npx cache:

1rm -rf ~/.npm/_npx

This will clear the global npx cache and you'll be able to use the latest version of the CLI tool.

Also, you can add an alias to your .zshrc or .bashrc file to make it easier to run:

1alias clearnpx="rm -rf ~/.npm/_npx"

If you've trouble finding where npm stores npx cache on your system, run the following command to find out the exact path to the _npx directory:

1npm config get cache

More Posts

Browse all posts

Aman Mittal author

I'm a software developer and a technical writer. On this blog, I write about my learnings in software development and technical writing.

Currently, working as the documentation lead at 𝝠 Expo. Read more about me on the About page.


Copyright ©  2019-2024 Aman Mittal · All Rights Reserved.