如何清除`npx`的中央缓存?

Fli*_*imm 9 npx

假设您正在运行此命令:

npx gulp
Run Code Online (Sandbox Code Playgroud)

npx将搜索gulpinside node_modules/.bin,如果在那里找不到,它将使用中央缓存。如果缺少,npx将安装它。

在这种情况下,如何清除中央缓存以强制npx重新安装gulp

Jam*_*s L 38

我需要这样做,因为 create-react-app 中出现错误,提示“我们不再支持 Create React App 的全局安装”。尽管没有全局安装。它卡在npx缓存中,我像这样删除它

npx clear-npx-cache
Run Code Online (Sandbox Code Playgroud)


fre*_*nte 14

在 macOS(可能还有 Linux)上~/.npm/_npx,它是,您可以使用以下命令删除它:

rm -rf ~/.npm/_npx
Run Code Online (Sandbox Code Playgroud)

在 Windows 上应该是 %AppData%/npm-cache/_npx


无论哪种方式,您都可以通过运行找到 npm 的缓存npm config get cache,然后在其中找到 npx 文件夹。

  • 为什么 NPX 保留需要显式清除的过时版本的软件包?似乎不对 (3认同)