Claude Code ENOSPC Disk Full Error (2026)
The Error
Error: ENOSPC: no space left on device, write
at Object.writeSync (node:fs:920:3)
at writeFileSync (node:fs:2254:26)
# Or:
npm ERR! code ENOSPC
npm ERR! syscall write
npm ERR! errno -28
npm ERR! nospc /tmp/npm-12345/package.tgz ENOSPC: no space left on device
# Or:
FATAL: Cannot write to /Users/you/.claude/cache — disk full
The Fix
- Check disk usage and identify space consumers
# Overall disk usage
df -h /
# Find largest directories in home
du -sh ~/Library/Caches/* 2>/dev/null | sort -rh | head -10
du -sh ~/.npm/ ~/.cache/ /tmp/ 2>/dev/null
- Clear caches that are safe to remove
# npm cache
npm cache clean --force
# Claude Code conversation cache
rm -rf ~/.claude/cache/*
# System temp files
rm -rf /tmp/npm-*
rm -rf /tmp/claude-*
# macOS specific
rm -rf ~/Library/Caches/com.apple.dt.Xcode/ # if you use Xcode
- Verify the fix:
df -h / | awk 'NR==2 {print "Available:", $4}'
claude --version
# Expected: Available: XX.XGi (enough free space) and version number
Why This Happens
Claude Code writes temporary files during operations — conversation state, file diffs, command output captures, and intermediate build artifacts. When the disk has less than ~100 MB free, these writes fail with ENOSPC. Common space hogs on developer machines include npm/pnpm caches (often 5-20 GB), Docker images, old build outputs, and accumulated node_modules directories across projects. The issue is more frequent on CI runners with small disk allocations or Docker containers with limited storage.
If That Doesn’t Work
- Alternative 1: Move npm cache to a larger partition:
npm config set cache /mnt/data/.npm-cache - Alternative 2: In Docker, increase the container’s disk allocation or mount a volume for temp files
- Check: Run
find / -xdev -type f -size +100M 2>/dev/null | head -20to find unexpectedly large files consuming space
Prevention
Add to your CLAUDE.md:
Run `df -h /` before long Claude Code sessions. Keep at least 2 GB free on the working disk. Clear npm cache monthly with `npm cache clean --force`. In CI, use disk cleanup actions before Claude Code steps.
Related articles: Claude Code Out of Memory Fix, Docker Build Failed Fix, Troubleshooting Hub
See Also
Related Error Messages
This fix also applies if you see variations of this error:
- Connection or process errors with similar root causes in the same subsystem
- Timeout variants where the operation starts but does not complete
- Permission variants where access is denied to the same resource
- Configuration variants where the same setting is missing or malformed
If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.
Frequently Asked Questions
Does this error affect all operating systems?
This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.
Will this error come back after updating Claude Code?
Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.
Can this error cause data loss?
No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.
How do I report this error to Anthropic if the fix does not work?
Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.
Find the right skill → Browse 155+ skills in our Skill Finder.
Related Guides
Try it: Paste your error into our Error Diagnostic for an instant fix.