🔧 Error Fixes
· 1 min read

npm Cache Issues — How to Clean and Fix


npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting
npm WARN using --force Recommended protections disabled.

npm’s cache can become corrupted, causing install failures, integrity errors, or stale packages.

Fix 1: Verify and Clean Cache

# Verify cache integrity
npm cache verify

# Force clean (if verify finds issues)
npm cache clean --force

Fix 2: Full Clean Install

# Nuclear option — delete everything and reinstall
rm -rf node_modules package-lock.json
npm cache clean --force
npm install

Fix 3: EINTEGRITY Error

# ❌ Package checksum doesn't match
# ✅ Delete lock file and cache
rm package-lock.json
npm cache clean --force
npm install

Fix 4: Wrong Package Version Installed

# ❌ npm installed an old cached version
# ✅ Force fresh download
npm install package-name --prefer-online

# Or clear cache first
npm cache clean --force
npm install package-name

Fix 5: Check Cache Location

# See where cache is stored
npm config get cache

# Default locations:
# macOS/Linux: ~/.npm
# Windows: %AppData%/npm-cache

# Check cache size
du -sh $(npm config get cache)

Fix 6: CI/CD Cache Issues

# ❌ CI caching stale node_modules
# ✅ Cache node_modules based on package-lock.json hash
# GitHub Actions:
# - uses: actions/cache@v3
#   with:
#     path: node_modules
#     key: ${{ hashFiles('package-lock.json') }}