Angular/CLI — auto reload doesn't happen

2020-05-18 07:13发布

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.

标签: angular-cli
12条回答
劫难
2楼-- · 2020-05-18 07:46

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.

  1. Open a terminal window.
  2. Type sudo chmod a+rwx /path/to/file into 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 command sudo chmod -R a+rwx /path/to/folder to 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.

  1. 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!

查看更多
Explosion°爆炸
3楼-- · 2020-05-18 07:47
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
查看更多
\"骚年 ilove
4楼-- · 2020-05-18 07:48

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

查看更多
相关推荐>>
5楼-- · 2020-05-18 07:49

run ng serve with sudo, it worked for me

sudo ng serve

This is only for Linux!

查看更多
贪生不怕死
6楼-- · 2020-05-18 07:51

If angular auto-reload is not working on ubuntu 20.04 and you are using nvm try running the following:

  1. sudo echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
  2. Delete node_modules in your application's folder
  3. npm uninstall -g @angular/cli
  4. npm cache verify
  5. npm install -g @angular/cli
  6. In your application's folder run npm i

Hopefully when you run ng serve everything should work as expected now.

查看更多
叼着烟拽天下
7楼-- · 2020-05-18 07:53

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
查看更多
登录 后发表回答