fen*_* ce 8 node.js npm npm-install
在我的服务器中,npm不缓存任何程序包,并且缓存目录为空。
#www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ nvm current
v9.4.0
# www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ npm config get cache
/home/www/.npm
# www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ ls
anonymous-cli-metrics.json _cacache _locks
Run Code Online (Sandbox Code Playgroud)
我的npm配置
www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ npm config ls
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v9.4.0 linux x64"
; node bin location = /home/www/.nvm/versions/node/v9.4.0/bin/node
; cwd = /home/www/.npm
; HOME = /home/www
; "npm config ls -l" to show all defaults.
Run Code Online (Sandbox Code Playgroud)
===== 更新
我发现在node@5.0 npm之后,将缓存数据存储在已配置的缓存中一个不透明的目录中,名为_cacache。https://docs.npmjs.com/cli/cache
www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ du -h --max-depth=1
56M ./_cacache
4.0K ./_locks
8.0K ./node-sass
56M .
Run Code Online (Sandbox Code Playgroud)
_cacache目录只有56MB
www@iZ2zefuufnen6rfx7c81u7Z:~/.npm$ npm cache verify
Cache verified and compressed (~/.npm/_cacache):
Content verified: 1164 (39196729 bytes)
Index entries: 1167
Finished in 1.321s
Run Code Online (Sandbox Code Playgroud)
==== 更新
我项目中的另一个测试。运行之后rm -rf node_modules && npm clean cache --force,然后run npm install在171.389s中添加了1551个软件包。然后rm -rf node_modules && npm install在152.378秒内添加了1551个程序包。npm真的使用缓存吗?
默认使用全局包缓存。如果您首先执行“npm 缓存清理”,您应该注意到安装时间有所不同。这将清除未全局安装的任何内容,对于那些您必须明确执行“npm卸载”的内容
| 归档时间: |
|
| 查看次数: |
5738 次 |
| 最近记录: |