node.js - 何时使用 npm 缓存,为什么?

标签 node.js npm

我什么时候必须使用 npm cache clean ? 而且,为什么在使用 npm cache clean 之后我会得到 info Trying

info trying registry request attempt 1 at 09:54:07

http GET https://registry.npmjs.org/delayed-stream/latest
http 304 https://registry.npmjs.org/delayed-stream/latest

最佳答案

Npm 将包缓存到一个目录中(Linux/OS X 上为 ~/.npm,Windows 上为 %AppData%/npm-cache)。

当您有多个基于 nodejs 的设置需要各种包作为依赖项时,这会有所帮助。 Npm 不会下载已经在缓存中的包,而是使用缓存中已经存在的包。因此,在这种情况下,它会尝试优化它必须执行的下载次数。

现在,关于您何时使用 npm cache clean。当由于某种原因我的缓存因不同依赖项的某些冲突版本而损坏时,我使用了它,或者您只是想清理您知道根本不需要的软件包,例如某些依赖项的旧版本。

基本上,在使用 npm cache clean 之后,就像全新安装 nodejs/npm 一样,除了全局安装的 node 模块(这些会一直保留到您使用 删除它们之前) >npm 卸载 命令)。

附加信息:https://docs.npmjs.com/cli/cache#configuration

关于node.js - 何时使用 npm 缓存,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20836317/

相关文章:

javascript - 从 fork 的 npm 包导入组件时出错

npm generator-ionic 安装需要 yo@>=1.0.0

javascript - DELETE api 请求响应 404 错误

node.js - 有没有办法让 puppeteer 的 waitUntil "networkidle"只考虑 XHR (ajax) 请求?

node.js - 在用 NodeJS 编写音频文件时读取它

javascript - MongoDB map-reduce(通过nodejs): How to include complex modules (with dependencies) in scopeObj?

java - Gradle 无法执行 npm 命令

javascript - 来自 github 的 npm 包,缺少文件

node.js - npm 安装错误 : rollbackFailedOptional

node.js - 错误 : The request signature we calculated does not match the signature you provided. 检查您的 key 和签名方法