0

I recently switched to Ubuntu from Windows and ng serve in Visual Studio Code is not auto compiling the code after every save.

I have to stop the terminal and fire the command again to compile my code.

Chirag Jain
  • 75
  • 1
  • 7
  • 1
    Possible duplicate of [ng serve not detecting file changes automatically](https://stackoverflow.com/questions/48092880/ng-serve-not-detecting-file-changes-automatically) – jonrsharpe Jun 13 '19 at 07:01
  • Yes the problem is same however the answer there is difficult to find for which I created a separate thread to answer the question effectively. – Chirag Jain Jun 13 '19 at 07:12
  • Also https://stackoverflow.com/questions/40366212/angular-cli-ng-serve-livereload-not-working, which has an answer quoting the exact same article as you – jonrsharpe Jun 13 '19 at 07:13
  • Thanks for pointing out the alike questions . will try to search more effectively before creating new thread. @jonrsharpe – Chirag Jain Jun 13 '19 at 07:22
  • `ng serve --poll=2000` , the reason is just that vs code does not have permission try running vs code as root – Joel Joseph Jun 13 '19 at 07:41
  • https://stackoverflow.com/questions/48092880/ng-serve-not-detecting-file-changes-automatically check this. – Gautham Srinivasan Jun 13 '19 at 09:20

2 Answers2

3

Listen uses inotify by default on Linux to monitor directories for changes. It's not uncommon to encounter a system limit on the number of files you can monitor. For example, Ubuntu Lucid's (64bit) inotify limit is set to 8192.

You can get your current inotify file watch limit by executing:

$ cat /proc/sys/fs/inotify/max_user_watches

When this limit is not enough to monitor all files inside a directory, the limit must be increased for Listen to work properly.

You can set a new limit temporary with:

$ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p

If you like to make your limit permanent, use:

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf

$ sudo sysctl -p

Source: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Chirag Jain
  • 75
  • 1
  • 7
0

some time auto refreshes not working so you can be forcing ng serve command using sudo before the command. like: sudo ng serve.

after that, you would not need compiling the code after every saves.