何时使用 npm 缓存,为什么? [英] When use npm cache and why?

查看:59
本文介绍了何时使用 npm 缓存,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When do I have to use npm cache clean ? And, why after using npm cache clean do I get 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 将包缓存到一个目录中(~/.npm on Linux/OS X and %AppData%/npm-在 Windows 上缓存).

Npm caches packages into a directory (~/.npm on Linux/OS X and %AppData%/npm-cache on Windows).

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

This helps when you have multiple nodejs based setups requiring various packages as dependencies. Npm wouldn't download a package which is already in the cache, instead would use the package from the cache if it's already there. Hence, in this case, it tries to optimise on the number of downloads it has to do.

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

Now, about when do you use npm cache clean. I've used it when for some reason my cache gets corrupted with some conflicting versions of different dependencies, or you simply want to clean up packages which you know you're not going to require at all, like maybe older versions of certain dependencies.

基本上,在使用 npm cache clean 之后,就像全新安装了 nodejs/npm,但全局安装的节点模块除外(这些模块会一直存在,直到您使用 npm uninstall 命令).

Basically, after using npm cache clean, it's like having a fresh installation of nodejs/npm with the exception of node modules installed globally (those will stay until you until you remove them with the npm uninstall command).

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

这篇关于何时使用 npm 缓存,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆