node.js - 从 NPM 缓存中清除 *just one* 包

标签 node.js npm npm-cache

问题:

有时我会跑

npm install x@latest

但它实际上并没有提取最新版本的包(那是蹩脚的)。

但是,如果我这样做:

npm cache clean --force && npm install x@latest

它会拉取最新的

但实际上我宁愿避免删除整个缓存而只删除单个包的缓存,例如:

npm cache clean x --force

但这似乎是不允许的。有人知道好的解决方法吗?

也许只是:

rm -rf $HOME/.npm/x

?

最佳答案

> npm cache ls vue@2.6.12
make-fetch-happen:request-cache:https://registry.npmjs.org/vue/-/vue-2.6.12.tgz
make-fetch-happen:request-cache:https://registry.npmjs.org/vue
make-fetch-happen:request-cache:https://registry.npmjs.org/vue

all list item is the cache key, then clean the cache by key

> npm cache clean make-fetch-happen:request-cache:https://registry.npmjs.org/vue/-/vue-2.6.12.tgz

> npm cache clean make-fetch-happen:request-cache:https://registry.npmjs.org/vue

> npm cache clean make-fetch-happen:request-cache:https://registry.npmjs.org/vue

or use shell to batch handle

npm cache ls vue@2.6.12 | xargs npm cache clean

关于node.js - 从 NPM 缓存中清除 *just one* 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49935118/

相关文章:

node.js - AggregateException : One or more errors occurred.(发生一个或多个错误。(无法启动 'npm'。要解决此问题:

node.js - npm-cache 目录下,_cacache 以外的文件夹是做什么用的?

node.js - 为什么我的 NPM 缓存文件夹位于 ./false/_cacache 中?

mysql - 'ER_PARSE_ERROR' 在 Node MYSQL 中运行查询时

node.js - 有谁知道如何将curl命令转换为node.js以用于firebase云功能

json - 如何批量插入600MB大json文件到elasticsearch?

npm - 在 Azure 管道中缓存 NPM 依赖项以获取内置 Windows 最新镜像

mysql - 无法从 Node.js 连接到 MySql 服务器

node.js - 询问对话框 (cli) 不理解 intent 中的 AMAZON.NUMBER 槽

node.js - 使用 Artifactory npm 支持