Getting "npm ERR! code ENOSPC" error on your VPS? This frustrating error stops npm installations and builds. This comprehensive guide explains why it happens and provides multiple solutions - including how to fix it without terminal knowledge using VPS Commander.
npm ERR! code ENOSPCnpm ERR! syscall writeENOSPC: no space left on devicenpm ERR! enospc ENOSPC: no space left on device, writeError: ENOSPC: System limit for number of file watchers reached
What is npm ERR! code ENOSPC?
ENOSPC stands for "Error NO SPaCe" and indicates your system has run out of a critical resource. On VPS servers, this error has two main causes:
- Actual Disk Space Issue: Your VPS storage is full
- File Watcher Limit: Linux inotify watch limit is reached (most common)
The confusing part? The error message says "no space" even when you have plenty of disk space. This is because Linux file watchers also count as "space."
Cause 1: Actual Disk Space Problems
Check Your Disk Usage
First, verify if you actually have disk space issues:
Method 1: Using Terminal
df -h
Look at the "Use%" column. If any partition shows 90%+ usage, you have a space problem.
Method 2: Using VPS Commander (No Terminal)
- Open VPS Commander dashboard
- View Server Stats section
- Check disk usage percentage in real-time
- Visual graphs show exactly what's consuming space
Solution: Free Up Disk Space
1. Clear npm Cache
Terminal:
npm cache clean --force
VPS Commander:
- Use Workflow Mode
- Select "Clean npm Cache" workflow
- Click Execute - done in one click
2. Remove Old node_modules
Finding and removing unused node_modules folders:
Terminal:
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
VPS Commander:
- Use File Manager
- Search for "node_modules" folders
- Select and delete with visual interface
- No complex find commands needed
3. Clean Package Manager Caches
# Yarn cache
yarn cache clean
# pnpm cache
pnpm store prune
# npm cache
npm cache clean --force
4. Remove Old Logs
Terminal:
sudo journalctl --vacuum-time=3d
sudo find /var/log -type f -name "*.log" -delete
VPS Commander:
- Navigate to
/var/login File Manager - Sort files by size
- Delete large old .log files visually
Cause 2: File Watcher Limit (Most Common)
This is the most common cause of ENOSPC errors on VPS, especially with Node.js development.
What Are File Watchers?
File watchers (inotify) monitor files for changes. Tools like webpack, nodemon, and VS Code use them extensively. Linux systems have a default limit of 8,192 watchers - modern Node.js projects easily exceed this.
Check Current Limit
cat /proc/sys/fs/inotify/max_user_watches
If this shows 8192 or less, you need to increase it.
Solution: Increase inotify Watches Limit
Method 1: Temporary Fix (Terminal)
This fixes the issue until next reboot:
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
Method 2: Permanent Fix (Terminal)
Make the change persist across reboots:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Method 3: Using VPS Commander (No Terminal)
- Open File Editor in VPS Commander
- Navigate to
/etc/sysctl.conf - Add this line at the end:
fs.inotify.max_user_watches=524288 - Save the file
- Use Workflow Mode to run "Reload System Settings"
Or simply ask the AI Assistant:
AI will execute the commands and verify the fix automatically.
Why 524288 Watches?
Each inotify watch consumes about 1KB of kernel memory. 524,288 watches ≈ 512MB RAM, which is reasonable for modern VPS servers. This limit supports:
- Multiple Node.js projects simultaneously
- Large monorepo codebases
- VS Code remote development
- Hot-reload development servers
Additional Solutions for ENOSPC Errors
1. Increase Swap Space
If your VPS has limited RAM, add swap space:
Terminal:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
VPS Commander:
- Select "Create Swap Space" workflow
- Choose size (1GB, 2GB, 4GB)
- Execute with one click
2. Optimize npm Install
Use these flags to reduce disk usage during installation:
# Skip optional dependencies
npm install --no-optional
# Use production mode
npm install --production
# Use npm ci instead of install
npm ci --production
3. Switch to pnpm (Saves 50-70% Disk Space)
pnpm uses hard links instead of copying packages:
npm install -g pnpm
pnpm install
A project that takes 500MB with npm takes only 150MB with pnpm!
4. Use .dockerignore or .gitignore
Prevent copying node_modules accidentally:
# .dockerignore
node_modules/
*.log
.npm
.cache
Prevention: Avoid ENOSPC Errors
1. Monitor Disk Usage Regularly
VPS Commander Dashboard shows real-time disk usage. Set up alerts when disk reaches 80% capacity.
2. Use .npmrc Configuration
Create .npmrc in your project:
# Reduce cache size
cache-max=1000
# Prefer offline mode
prefer-offline=true
# Progress false (saves memory)
progress=false
3. Regular Cleanup Script
Create a weekly cleanup cron job:
# Clean npm cache weekly
0 0 * * 0 npm cache clean --force
Or use VPS Commander's Scheduled Tasks to automate this visually.
4. Upgrade VPS Storage
If you consistently hit storage limits, upgrade your VPS plan. Most providers offer easy upgrades starting at $5-10/month.
Fix ENOSPC During Specific Operations
During npm install
# Increase memory limit
node --max-old-space-size=4096 $(which npm) install
During webpack build
# Increase Node.js memory
export NODE_OPTIONS="--max-old-space-size=4096"
npm run build
During Docker build
# Use BuildKit with better caching
DOCKER_BUILDKIT=1 docker build -t myapp .
VPS Commander: The Easy Way to Fix ENOSPC
Why Use VPS Commander?
- Visual Disk Monitoring: See exactly what's using space
- One-Click Solutions: Fix inotify limits without commands
- AI Troubleshooting: Describe the error, get automatic fixes
- File Manager: Delete old files and folders visually
- Workflow Automation: Pre-built workflows for common fixes
- No Terminal Needed: Everything in web interface
Fixing ENOSPC with VPS Commander in 3 Steps
- Diagnose: Check disk usage in Server Stats dashboard
- Fix: Use AI Assistant: "Fix npm ENOSPC error"
- Verify: AI confirms the fix and runs npm install successfully
Time required: 2-3 minutes (vs 20-30 minutes manually troubleshooting)
Troubleshooting: Error Still Persists
1. Check Specific Directory Space
du -sh /tmp
du -sh ~/.npm
du -sh node_modules
2. Check Inode Usage
Sometimes you run out of inodes (file pointers) not space:
df -i
If "IUse%" is near 100%, delete many small files.
3. Restart Node.js Process
pm2 restart all
4. Reboot VPS
Last resort if all else fails:
sudo reboot
With VPS Commander, just click "Restart Server" button.
Platform-Specific Solutions
Ubuntu/Debian VPS
sudo apt clean
sudo apt autoremove
sudo apt autoclean
CentOS/RHEL VPS
sudo yum clean all
sudo package-cleanup --oldkernels --count=1
Docker Containers
docker system prune -a
docker volume prune
Conclusion: Never Let ENOSPC Stop You
The npm ENOSPC error is frustrating but easily fixable. In most cases, it's the inotify watches limit, not actual disk space. With VPS Commander, you can diagnose and fix these issues without memorizing complex Linux commands.
Quick Recap:
- ENOSPC usually means inotify limit, not disk space
- Increase watches limit to 524288 for Node.js development
- Clean npm cache and old node_modules regularly
- Use VPS Commander for visual troubleshooting
- AI Assistant can fix the error automatically
- pnpm saves 50-70% disk space vs npm
Fix ENOSPC Errors Without Terminal
Use VPS Commander's visual interface and AI Assistant to solve npm errors in minutes.
Start Free Trial →Frequently Asked Questions
Why does npm say "no space" when I have 50GB free?
The error message is misleading. It's usually the inotify watches limit (8,192 default), not disk space. Increase it to 524,288.
Is 524288 watches safe for my VPS?
Yes! It uses about 512MB RAM. Any VPS with 1GB+ RAM handles this easily.
Will this fix persist after reboot?
Only if you edit /etc/sysctl.conf. The sysctl command alone is temporary.
Can I use this fix on shared hosting?
No. Shared hosting doesn't give you root access. You need VPS for system-level changes.
Does VPS Commander work with all VPS providers?
Yes! Works with DigitalOcean, Linode, Vultr, AWS, Google Cloud, Azure, Hetzner, OVH, and any VPS with SSH access.