Error: ENOSPC: System limit for number of file watchers reached
Error: watch /home/user/project/src ENOSPC
Your development tools (Vite, Webpack, nodemon, VS Code) use file watchers to detect changes. Linux has a default limit of 8,192 watchers β large projects easily exceed this.
Fix (Permanent)
# Increase the limit
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
# Apply immediately
sudo sysctl -p
Thatβs it. This sets the limit to 524,288 watchers and persists across reboots.
Fix (Temporary β Until Reboot)
sudo sysctl fs.inotify.max_user_watches=524288
Check Current Limit
cat /proc/sys/fs/inotify/max_user_watches
Why This Happens
Dev tools watch every file in your project for changes. A typical Node.js project with node_modules has thousands of files. Multiple tools running at once (VS Code + Vite + Jest) multiply the count.
WSL Users
The same fix works in WSL. Open your WSL terminal and run the permanent fix above.
If You Canβt Change System Settings
Reduce the number of watched files instead:
# Exclude node_modules from watching (Vite)
# vite.config.ts
export default {
server: {
watch: {
ignored: ['**/node_modules/**'],
},
},
};
# Exclude in nodemon
# nodemon.json
{
"ignore": ["node_modules", "dist", ".git"]
}