Applies to: npm 11 with Node.js 24 LTS (tested with npm 11.17 and Node.js 24.19 on AlmaLinux 9)
npm keeps a copy of every package it downloads in a cache, so the next install is faster. Clearing it is rarely needed, but it helps when installs fail with strange integrity or “corrupted” errors, or when you want the disk space back.
Where the cache is
npm config get cache # usually ~/.npm on Linux and macOS du -sh ~/.npm/_cacache
On Windows it is %LocalAppData%\npm-cache.
Clear it
npm cache clean --force
Without --force, npm refuses. Our test printed:
npm error As of npm@5, the npm cache self-heals from corruption issues by treating integrity mismatches as cache misses. npm error As a result, data extracted from the cache is guaranteed to be valid. npm error If you want to make sure everything is consistent, use `npm cache verify` instead.
With --force it warns npm warn using --force Recommended protections disabled. and removes the _cacache folder.
Check it instead of deleting it
npm cache verify
This checks the cache, removes unneeded data and reports the result, for example Cache verified and compressed (~/.npm/_cacache). Try this first.
When an install keeps failing
npm cache verify- Delete the project’s installed packages and reinstall:
rm -rf node_modules, thennpm ci(with apackage-lock.json) ornpm install. - Only if that doesn’t help:
npm cache clean --forceand install again. - Check the Node.js version the project needs (
node -v).
Other package managers
yarn cache clean pnpm store prune
Installing Node.js and npm: install Node.js and npm on Linux.