npm Cache
·
1 min read
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 Manager | Cache Directory |
---|---|
Maven | /root/.m2/ |
Gradle | /root/.gradle/ |
npm | /root/.npm/ |
composer | /root/.cache/composer/ |
yarn | /usr/local/share/.cache/yarn/ |
Final Thoughts
Done.