brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: npm cache verify checks and tidies npm's download cache

Cache
~/tips/tip-npm-cache-verify

npm cache verify

Check the package cache for damage and clear out unneeded data safely.

When an install fails in a strange way, deleting the whole cache is the reflex. There is a gentler step I would try first.

npm cache verify

It goes through the cache folder, checks that the stored data and the index are intact, and garbage collects whatever is no longer needed. At the end it reports how much content it verified and how many index entries there are. Your good downloads stay, so the next install does not have to fetch everything again.

To see where the cache lives:

npm config get cache

The full wipe is npm cache clean --force. npm’s own documentation says that is typically unnecessary, because the cache heals itself and is resistant to corruption. The --force is there to make you think twice.

So if an install still fails after a verify, I would look elsewhere: the lock file, the registry address, your proxy, the Node version. A verify can take a while on a large cache. It also only concerns the download cache, not the node_modules folder inside your project.

Further reading: npm docs: npm cache

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Cache tips fincore /var/lib/example/data.db fc-cache -f -v ~/.local/share/fonts proxy_cache app; Cache-Control: no-cache Cache-Control: max-age=60, stale-while-revalidate=600 All Cache tips (24) All topics

Link