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

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 a documentation lead at  Expo.