npm cache clean Explained
What npm cache clean does, with an example.
Published November 11, 2026
npm cache clean --force deletes the local npm cache. Normally the cache self-heals, so cleaning is a troubleshooting step for corrupt downloads, not routine maintenance.
How it works
The cache lives in ~/.npm (_cacache). npm cache verify checks and garbage-collects it safely.
Clean it when you see integrity or tarball errors.
Try it
npm cache verify
Cache verified and compressed
npm cache clean --force
Practical examples
Verify first
npm cache verifyForce clean
npm cache clean --forceLocate the cache
npm config get cacheFull reset
rm -rf node_modules package-lock.json
npm cache verify
npm installCommon mistakes
- Cleaning the cache for every problem.
- Forgetting --force.
- Deleting lockfiles unnecessarily.
Key takeaways
- npm cache clean --force deletes the local npm cache.
- Run npm help <command> for every option.
- Commit package-lock.json.
FAQ
Is cleaning safe?
Yes, but it slows the next installs.
Does this work with yarn or pnpm?
They have equivalents with similar commands.