npm Cache

npm Cache

2月 13, 2025 · 1 分钟阅读时长 · 114 字 · -阅读 -评论

When developing with npm, you may notice that if you delete the node_modules folder and then reinstall dependencies, the installation is very fast. This is because npm has a caching mechanism.

What is npm Cache

npm cache is a mechanism where npm downloads dependency packages to a local cache directory during installation. The next time you install, if the dependency package already exists in the cache directory, npm retrieves it directly from the cache instead of downloading it again.

How to View npm Cache


npm config get cache

npm cache ls

Cache Directories for Different Package Managers

Package ManagerCache Directory
Maven/root/.m2/
Gradle/root/.gradle/
npm/root/.npm/
composer/root/.cache/composer/
yarn/usr/local/share/.cache/yarn/

Final Thoughts

Done.

Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源