Skip to content

How to clear global npx cache

Published:

1 min read

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

A new version of "x-package" is available
You 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:

rm -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:

alias 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:

npm config get cache

Previous Post
Resolve merge conflicts with git rebase
Next Post
Bypass CORS to fetch files when working with localhost

I'm a software developer and technical writer. On this blog, I share my learnings about both fields. Recently, I have begun exploring other topics, so don't be surprised if you find something new here.

Currently, working as a documentation lead at Expo.