Angular "ENOSPC: System limit for number of file watchers reached" in CI
Angular's watch mode registers an inotify watcher per file. On a Linux runner with a low max_user_watches limit, a large project exhausts the limit and the build or serve fails with ENOSPC, even though disk space is fine.
What this error means
A watch build or ng serve in CI fails with "ENOSPC: System limit for number of file watchers reached", unrelated to actual disk space.
Error: ENOSPC: System limit for number of file watchers reached, watch
'/home/runner/work/app/app/src/app/feature'
at FSWatcher.<computed> (node:internal/fs/watchers:...)Common causes
Running a watch build in CI
Watch mode opens an inotify watcher per file; CI does not need watching, so the limit is hit for no benefit.
A low inotify watcher limit on the runner
The kernel fs.inotify.max_user_watches is set low, and a large source tree exceeds it.
How to fix it
Disable watch in CI
- Run builds and tests in single-run mode, not watch.
- Use
--watch=falseforng testand avoidng servein CI. - Re-run the job.
ng test --watch=false
ng build # one-shot build does not watchRaise the watcher limit if watching is required
When a watch is genuinely needed, increase the kernel limit before the step.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -pHow to prevent it
- Use one-shot builds and
--watch=falsetests in CI. - Do not run
ng servein pipelines. - Raise
max_user_watchesonly on runners that must watch.