在 Debian 上清理 Node.js 相关缓存,通常看你指的是哪一类缓存。下面按常见场景说明:
如果你是用 npm 安装的包:
npm cache clean --force
查看缓存目录位置:
npm config get cache
一般路径是:
~/.npm
也可以手动删除:
rm -rf ~/.npm/_cacache
如果你用的是 yarn:
yarn cache clean
缓存目录:
yarn cache dir
如果你用的是 pnpm:
pnpm store prune
或查看缓存路径:
pnpm store path
项目本地的依赖缓存:
rm -rf node_modules
npm install
或(yarn):
rm -rf node_modules yarn.lock
yarn install
如果你是通过 Debian 的 apt 安装的 Node.js:
sudo apt clean
或只清 Node 相关:
sudo apt-get clean nodejs
查看已安装版本:
node -v
npm -v
Node.js 本身没有全局缓存机制,如果你指的是:
require 缓存)那就需要:
delete require.cache[require.resolve('./module')]
或重启 Node 服务:
systemctl restart yourapp
如果你能补充说明:
我可以给你更精确的命令。