npm清除缓存

npm 版本在 7.0.0 以上则不需要清除缓存。

# npm version < 7.0.0
$ npm cache clean -f
# npm version ≧ 7.0.0 会报以下错误
$ npm cache clean

npm ERR! As of npm@5, the npm cache self-heals from corruption issues
npm ERR! by treating integrity mismatches as cache misses.  As a result,
npm ERR! data extracted from the cache is guaranteed to be valid.  If you
npm ERR! want to make sure everything is consistent, use `npm cache verify`
npm ERR! instead.  Deleting the cache can only make npm go slower, and is
npm ERR! not likely to correct any problems you may be encountering!
npm ERR! 
npm ERR! On the other hand, if you're debugging an issue with the installer,
npm ERR! or race conditions that depend on the timing of writing to an empty
npm ERR! cache, you can use `npm install --cache /tmp/empty-cache` to use a
npm ERR! temporary cache instead of nuking the actual one.
npm ERR! 
npm ERR! If you're sure you want to delete the entire cache, rerun this command
npm ERR! with --force.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxxxxx/.npm/_logs/2021-02-04T06_35_38_043Z-debug.log

翻译过来是

在 npm@5 中,npm 缓存通过将完整性不匹配视为缓存丢失来自修复损坏问题。
因此,从缓存中提取的数据保证是有效的。如果你想确保一切都是一致的,那就用 npm cache verify 吧。
删除缓存只会让 npm 运行得更慢,而且不太可能纠正你可能遇到的任何问题!

另一方面,如果你在调试安装程序的问题,或者依赖于写入空缓存的时间的竞争条件,
你可以使用 'npm install --cache /tmp/empty-cache' 来使用一个临时缓存,而不是使用实际的缓存。
如果您确定要删除整个缓存,请使用 '--force' 重新运行此命令。
  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值