Reputation: 1156
I have a simple Angular app, that is a collection of small example apps.
(The code can be found on GitHub, and the homepage is here.)
I work on it locally.
Suddenly the following error is all over my console, when I do ng serve
:
Watchpack Error (watcher): Error: ENOSPC:
System limit for number of file watchers reached,
watch '/home/tilman/Code/angular_examples/node_modules/blah/blah'
But the app still works. There seems to be no problem, except my flooded console.
Some details:
Ubuntu 20.04
PyCharm 2024.1.3 (Professional Edition)
Angular CLI: 13.3.4
Node: 17.9.0 (Unsupported, according to ng v
)
Package Manager: npm 8.5.5
/proc/sys/fs/inotify/max_user_watches
: 65536
Similar questions have been asked about React in 2019 and about Angular in 2021.
The answers mostly sound like: Pressing some buttons worked for me.
But I would like to know what is going on here.
I was not aware, that file watchers are a thing.
Do I need them? Where are they? Why are there so many? How to clean them up?
One of the proposed solutions is deleting and reinstalling node_modules
.
That is not a good way to solve problems. (What if something is gone, when I try to reinstall it?)
One answer to the React question sounds quite reasonable:
add watchOptions: { ignored: /node_modules/ }
to webpack.config.js
I just don't have that file.
Initially the errors are for all kinds of folders in node_modules
.
Eventually only these four are repeated in a loop:
/home/tilman/Code/angular_examples/node_modules/jquery/dist
/home/tilman/Code/angular_examples/node_modules/jquery
/home/tilman/Code/angular_examples/node_modules/typescript/lib
/home/tilman/Code/angular_examples/node_modules/typescript
Here is a screenshot, showing Compiled successfully among the error messages:
Edit: A popup in Pycharm sends me to this support page: Inotify Watches Limit (Linux)
There I am told, that I should just increase the number of allowed watchers.
A user asks about the same problem, also in an Angular project.
The answer is, that folders can not be excluded from watching.
But there is a proposal that users can vote for: https://youtrack.jetbrains.com/issue/IJPL-2175
Anyway, I have added node_modules
to the excluded folders, and now the problem is gone. (It was already orange, but ulike dist
and tmp
it did not appear in the list.)
Upvotes: 0
Views: 168
Reputation: 1156
The solution is of course not to watch files in node_modules
.
(Because nothing there is supposed to be changed.)
I have added it to the excluded folders in Pycharm. Apparently that worked.
(See screenshot at the end of the question.)
Upvotes: 0