什么时候使用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/OSX上为~/.npm,Windows上为%AppData%/npm-cache)。

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

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

基本上,在使用npm cache clean之后,除了全局安装的节点模块之外,就像重新安装nodejs/npm一样(这些模块将一直保留到您使用npm uninstall命令删除它们为止)。

其他信息:https://docs.npmjs.com/cli/cache#configuration

最新更新