Ng cannot automatically detect file changes

I need to run ng serveevery time any changes made to the source files. I have no error in the console.

Angular CLI: 1.6.2
Node: 8.9.1
OS: linux ia32
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.2-c3d7cd9
@angular/cli: 1.6.2
@angular/material: 5.0.3-e20d8f0
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.2
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0
+66
source share
22 answers

In most cases, Linux ng serve --watcheither ng build --watchdoes not work if the directory does not have sufficient permissions.

The solution is to either provide the necessary permissions or use instead sudo.

UPDATE

The watch flag is ng serveactually redundant, as this is the default option. Thanks to @Zaphoid for pointing out the error.

+99
source
ng serve --poll=2000

Works fine on Linux and Windows

+75
source

, INotify Watches Linux. , , 512 .

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

, , .

, :

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

: https://github.com/angular/angular-cli/issues/8313#issuecomment-362728855 https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

+48

- , , , .

change the amount of watches, ( , ), run this command:

echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches

inotify , .

+22

dist

sudo ng serve ng serve.

, linux. INotify Watches Linux. ,

//When live server not work in linux

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

ng serve //You can also do sudo **ng serve**
+12

, Windows ng serve --poll = 2000 .

ng serve --poll=2000

+6

sudo.

+6

, , . ng serve ng build --watch , , , - ng.

,

Ubuntu, , , :

echo fs.inotify.max_user_watches = 524288 | sudo tee/etc/sysctl.d/40-max-user-watches.conf & sudo sysctl --system

+5

, dist/ root. sudo ng serve , ng serve - .

dist/folder sudo rm -R dist/ , dev server ng serve sudo rm -R dist/.

+2

, , index.html, , , . Angular.

, VS Code. ng serve , : . . , html- HTML- ( HTML <!doctype html>. , HTML HTML HTML.

bam, ( ).

, index.html , , , , , , VS Code , , .

+1

Linux Ubuntu , " " VSCode. , VSCode, ng watch. https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

, sudo . , npm root . , , , , sudo root, , ( , vscode atom ). - , / chown.

+1

sudo ng serve - . npm , npm packages sudo.

, npm , npm node_modules npm install. ng serve sudo ng serve , .

+1

: sudo ng serve , "" . sudo IMO.

INotify (8192), : lsof | grep inotify | wc -l lsof | grep inotify | wc -l lsof | grep inotify | wc -l , , , . , INotify, , .

, , .

- VS Code. , , , .

-. , , . / , , , .

0

.

sudo ng serve
0

VS .

0

SO. fs.inotify.max_user_watches () , ...

"Ng serve --poll = 2000" - , , , ...

: https://github.com/angular/angular-cli/wiki/angular-cli .

de angular.json

"serve": {
   "builder....
   "options": {
        "browserTarget": "xkcd:build",
        "poll": 2000
   }
   ...

: D

0

, ng serve sudo . : sudo ng serve.

.

0

. - .

, , . .

0

I would like to leave my business here, just for reference. In my case, the problem was in system permissions. I used the shared folder inside the virtual machine as a repository. I did not have another message, for example, permission denied or something else. I tried everything and then I just realized that I was using a network drive.

0
source

Restarting the server worked for me.

0
source

If you are using the WebStorm IDE, use Save All( Ctrl+ s) after making the changes .

-1
source

Source: https://habr.com/ru/post/1691730/


All Articles