'Angular/CLI -- auto reload doesn't happen
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.
Solution 1:[1]
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Solution 2:[2]
Ng serve automatically reload when the files are modified however if the config is messed up then you can try bellow command
ng serve --live-reload
Solution 3:[3]
run ng serve with sudo, it worked for me
sudo ng serve
This is only for Linux!
Solution 4:[4]
Just run all the following command and I hope it will work.
rm -rf nodes_modules/
npm update
npm install
and start the server again
ng serve -o
Solution 5:[5]
I am using angular 6 and increasing time on max_user_watches worked for me
sudo echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
Solution 6:[6]
it works for me: ng serve --poll=1000
Solution 7:[7]
I have faced the same issue in my ubuntu machine. It was due to the permission settings. I changed the workspace permission settings by following the below mentioned steps.
- Open a terminal window.
- Type
sudo chmod a+rwx /path/to/fileinto the terminal, replacing “/path/to/file” with the file you want to give permissions to everyone for, and press “Enter.” You can also use the commandsudo chmod -R a+rwx /path/to/folderto give permissions to a folder and every file and folder inside it. Omit the “x” from either command if you don’t want the files to be executable.
I have used sudo chmod -R a+rwx /path/to/folder.
- Type your password at the password prompt and press “Enter.”
Once it is done, do npm build and start the application by ng serve.
[OR]
Simply you can use "sudo ng serve".
Now do the necessary changes in the workspace files and without restart, auto-reload happens. Hope this would be helpful!
Solution 8:[8]
If angular auto-reload is not working on ubuntu 20.04 and you are using nvm try running the following:
- sudo echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
- Delete node_modules in your application's folder
- npm uninstall -g @angular/cli
- npm cache verify
- npm install -g @angular/cli
- In your application's folder run npm i
Hopefully when you run ng serve everything should work as expected now.
Solution 9:[9]
I encountered this issue because I used WSL to run commands for a project that was under a Windows directory (/mnt/...).
To resolve it, I transferred the project directory on the WSL directory (~/).
Solution 10:[10]
Solution 11:[11]
I met the problem when my devDependencies is Angular 7
but install angular/cli of version 8.x.x
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.8",
"@angular/cli": "^7.3.8",
"@angular/compiler-cli": "^7.2.12",
}
just remove the cli globally
npm unintsall -g @angular/cli
npm cache clean -f
check the state
ng version # if remove successfully, the command would no work
then install cli again
sudo npm install @angular/cli@^7.3.8 -g
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow

