npm cache clean and verify — fix corrupted installs
Quick Answer
# Verify cache integrity (safer — reports issues)
npm cache verify
# Clean the cache (clears all cached data)
npm cache clean --force
# After cleaning, reinstall
rm -rf node_modules package-lock.json
npm install
Usage
A package install fails with a checksum mismatch or corrupted files, even after retrying.
Other causes & fixes
Cache location
# Find where npm stores cache
npm config get cache
# Usually: ~/.npm (Linux/macOS) or %AppData%/npm-cache (Windows)
Offline installs using cache
# Use cached packages without a network request
npm install --prefer-offline
# Force a fresh download (ignore cache)
npm install --prefer-online
Check npm and Node.js versions
node --version
npm --version
# Update npm
npm install -g npm@latest
Related