The ENOSPC error occurs when npm cannot write files due to insufficient disk space. Clear npm cache, remove node_modules, or free up disk space to resolve this.
ENOSPC is a system-level error indicating the filesystem has no available space. npm needs to write files during installation - packages, cache data, and temporary files. When the disk is full, all write operations fail. This error can also occur on systems with inode exhaustion (many small files) even if there's technically space available.
Verify space usage:
df -h
# Check specific directory
du -sh /home
du -sh ~/.npm
du -sh node_modulesRemove cached packages:
npm cache clean --force
# Check cache size first
npm cache ls
du -sh ~/.npm/_cacacheClear installed packages:
rm -rf node_modules
# Find and remove all node_modules
find . -name "node_modules" -type d -prune -exec rm -rf {} +Clean system temp:
# Remove old temp files
sudo rm -rf /tmp/*
# Clear npm temp
rm -rf ~/.npm/_logs
rm -rf ~/.npm/_npxVerify inode usage:
df -i
# If low on inodes, find directories with many files
find / -xdev -printf "%h\n" | sort | uniq -c | sort -n | tail -20Remove unneeded files:
# Find large files
find / -type f -size +100M 2>/dev/null
# Clean docker
docker system prune -a
# Clean package manager cache
sudo apt clean # Debian/UbuntuIn CI/CD, use cache strategies that share npm cache across runs but clean node_modules. Docker images should use multi-stage builds to minimize size. Consider using pnpm for space-efficient dependency management. Set up monitoring for disk space to catch issues early. For persistent issues, consider expanding disk capacity.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error