Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-cli ng serve livereload not working

I have created a sample project wiht Ng-cli, then i run ng serve in the source folder, the project loads correctly in the browser but livereload not working.

npm -v : 3.10.9

ng -v: angular-cli: 1.0.0-beta.19-3 node: 4.4.3 os: win32 x64

Already searched a lot information on internet, and nothing solved the issue.

like image 690
Anton Selin Avatar asked Nov 01 '16 18:11

Anton Selin


3 Answers

I faced with the same problem on Ubuntu 16.04 and angular CLI 1.0.0.

The problem was related with Inotify Watches Limit on Linux. To solve the issue, I increased the watches limit to 512K. Run these commands.

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

After that, I restarted my IDE, and after that, the change detection started to work.

like image 153
neetesh Avatar answered Oct 20 '22 09:10

neetesh


Increasing the amount of inotify watchers

The technical details

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

You may also need to pay attention to the values of max_queued_events and max_user_instances if Listen keeps on complaining.

Source

like image 43
mQuiroz Avatar answered Oct 20 '22 10:10

mQuiroz


Try ng serve -lr flag. This flag works with me. Probably the issue occurs becuase --live-reload flag is deprecated

like image 5
Alex Link Avatar answered Oct 20 '22 08:10

Alex Link