I have an Angular project on Linux that generally works.
Angular CLI: 13.3.9
Node: 16.14.2
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1202.18
@angular-devkit/build-angular 13.3.9
@angular-devkit/core 12.2.18
@angular-devkit/schematics 13.3.9
@angular/cli 13.3.9
@schematics/angular 13.3.9
rxjs 7.5.6
typescript 4.6.4
But when trying to ng serve
the project, I am sometimes getting an endless stream of error messages such as
Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/me/my_project/node_modules/libp2p-utils/dist'
so I have to stop the process and then ng serve
fails.
I wanted to solve this problem so I found this answer:
https://stackoverflow.com/a/72423671
I followed the instructions and then based on the following documentation
https://webpack.js.org/configuration/watch/#watch
I went ahead and had the following content in the new webpack.config.js
file that I created:
module.exports = {
//...
watch: false,
};
Now, I think that that was supposed to make Webpack not watch any file.
But when I do ng serve
, again I am getting what seems to be the same error messages as before. It seems like Webpack keeps watching those node_modules
files.
I think the ng serve
does see the webpack.config.js
file, because when I change the setting to watch: blah,
, I am getting the error message
An unhandled exception occurred: blah is not defined
I have also tried the following:
module.exports = {
//...
watchOptions: {
ignored: '**/node_modules',
},
};
But again, the same error messages.
Why doesn't the Webpack config work as expected?