ng serve not detecting file changes automatically
Most of the times in Linux,
ng serve or
ng build --watch doesn't work if the directory doesn't have sufficient permissions.
The solution is either to provide the necessary permissions or to use
watch flag in
ng serve is actually redundant as it is the default option. Credit to @Zaphoid for pointing out the mistake.
Consider that, when having a large number of files, there is a Limit at INotify Watches on Linux. So increasing the watches limit to 512K, for example, can solve this.
sudo sysctl fs.inotify.max_user_watches=524288sudo sysctl -p --system
Note that the previous causes an in-memory change that you will lose after restart.
However, you can make it persistent, by executing:
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system