I recently started working with Angular/CLI tool, I'm facing a problem while executing the file, that is when I run
ng serve
then this command helps us in auto reloading the site when any changes are made in the source file but in my system it is not happening (i.e. site is not auto reloading and when I forcely reload the site then also it is not getting updated as per changes made in the source file).
The site is getting updated only when I terminate the "ng serve" command and again run the same command("ng serve") then only my site is getting updated.
So it becomes hard for me to terminate the server and connect the server, when ever the changes are made, so I request you people if any one know solution of this problem please help me out.
I also encountered the same problem a few days back in my linuxOS, and when I read about it, I found that this problem is heavily dependent on the system you use and the way you did your setup for angular-cli, both globally and locally. So, after reading readme.md created by angular-cli for each project, I tried using
ng-build --watch
but the problem still couldn't be solved because by running this command it should work likeng-serve
but it only build the app and doesn't even served it onlocalhost:4200
. then, after digging into the problem more deeper I found the problem, it was with my OS, I am using ubuntu, theinotify/max_user_watches
value 8192, which I crossed, due to which it wasn't showing any changes made further. So i used these-echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf sudo sysctl -p
and it worked fine.p.s. in the process i also tumbled upon a solution with these commands -
rm -rf nodes_modules/
->npm update
->npm install
. try this before doing above stated canges, if this works for you then you are well and good to go.I met the problem when my devDependencies is Angular 7
but install
angular/cli
of version8.x.x
just remove the cli globally
check the state
then install cli again
@Durga Abhist I am using a Linux machine. I simply solved watch issue by just open the project path in the terminal in sudo mode. I did not do anything else.
Just run all the following command and I hope it will work.
and start the server again
If you are using Linux system then the below command may be helpful for you
Run below command in terminal
sudo ng serve
It works for me !!