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') }}