我何时必须使用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
答案 0 :(得分:11)
Npm将软件包缓存到目录(Linux / OS X上的~/.npm
和Windows上的%AppData%/npm-cache
)。
当您有多个基于nodejs的设置需要各种包作为依赖项时,这会有所帮助。 Npm不会下载已经在缓存中的软件包,而是使用缓存中的软件包(如果它已经存在)。因此,在这种情况下,它会尝试优化它必须执行的下载次数。
现在,您何时使用npm cache clean
。我出于某种原因使用它时,我的缓存因不同依赖项的某些冲突版本而被破坏,或者您只是想清理您根本不需要的软件包,例如某些依赖项的旧版本。
基本上,在使用npm cache clean
之后,就像全局安装了节点模块一样全新安装了nodejs / npm(除非你用npm uninstall
命令删除它们,否则它们会保留到你之前) 。