Cómo solucionar Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch ...

Problema

En Linux, ves un mensaje de error como

watchpack_error_output.txt
Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/uli/dev/myproject/node_modules/@primeuix'

Solución

Este error ocurre a menudo si tu IDE, como Visual Studio Code, está vigilando espacios de trabajo enormes, la mayoría de las veces con directorios node_modules.

Generalmente, puedes simplemente aumentar el límite:

increase_inotify_limits.sh
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
echo fs.inotify.max_user_instances=16384  | sudo tee -a /etc/sysctl.conf
echo fs.inotify.max_queued_events=32768 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Sin embargo, también recomiendo configurar VS Code para no vigilar esas rutas:

  • Abre Preferences -> Open User Settings (JSON) y añade lo siguiente:
vscode_watcher_settings.json
"files.watcherExclude": {
  "**/node_modules/**": true,
  "**/dist/**": true,
  "**/.git/**": true
}

Echa un vistazo a artículos similares por categoría: Linux