【发布时间】:2018-01-16 04:48:36
【问题描述】:
在我的服务器中,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
我的 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.
=====更新
发现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 .
_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
====更新
我的项目中的另一个测试。
运行rm -rf node_modules && npm clean cache --force 后,run npm install 在 171.389 秒内添加了 1551 个包。然后rm -rf node_modules && npm install 在 152.378 秒内添加了 1551 个包。 npm 真的使用缓存吗?
【问题讨论】:
标签: node.js npm npm-install