angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

webpack live reload is not working.

Open burdzand opened this issue 10 years ago • 100 comments

I have installed the webpack but the live reload is not working , it is building the modules and caching it.

Linux 4.4.0-31-generic node v6.2.2 npm v3.10.5

angular-cli: 1.0.0-beta.11-webpack node: 6.2.2 os: linux x64

burdzand avatar Aug 09 '16 14:08 burdzand

Are you using the ng serve command or ng build --watch.

Both should work but I ask because we really need more information to accurately tackle this.

TheLarkInn avatar Aug 09 '16 14:08 TheLarkInn

I am using ng serve

burdzand avatar Aug 09 '16 14:08 burdzand

10% building modules 1/1 modules 0 active
* * NG Live Development Server is running on http://localhost:4200. * 4318ms building modules
38ms sealing 0ms optimizing 0ms basic module optimization 16ms module optimization 1ms advanced module optimization 15ms basic chunk optimization
1ms chunk optimization 0ms advanced chunk optimization 0ms module and chunk tree optimization 58ms module reviving 5ms module order optimization 4ms module id optimization 3ms chunk reviving 0ms chunk order optimization 14ms chunk id optimization 26ms hashing 1ms module assets processing 71ms chunk assets processing 2ms additional chunk assets processing 1ms recording 0ms additional asset processing 127ms chunk asset optimization 864ms asset optimization 25ms emitting Hash: 3eaa2255197a9b5cb5fd Version: webpack 2.1.0-beta.18 Time: 5607ms Asset Size Chunks Chunk Names main.bundle.js 2.18 MB 0, 2 [emitted] main polyfills.bundle.js 227 kB 1, 2 [emitted] polyfills inline.js 4.96 kB 2 [emitted] inline main.map 2.59 MB 0, 2 [emitted] main polyfills.map 294 kB 1, 2 [emitted] polyfills inline.map 5.13 kB 2 [emitted] inline index.html 476 bytes [emitted]
.npmignore 0 bytes [emitted]
Child html-webpack-plugin for "index.html": Asset Size Chunks Chunk Names index.html 2.4 kB 0
webpack: bundle is now VALID.

burdzand avatar Aug 09 '16 14:08 burdzand

I'm seeing the live reload working myself. Can you give very exact repro steps so we can see if there's something missing?

filipesilva avatar Aug 18 '16 03:08 filipesilva

I am having the same issue after I cloned a project from my repo.

On my regular machine, I see a lot of something like "69% building modules 1054/1062 modules 8 active ..", etc.

But on my other machine, I only see this -

 ng serve
 10% building modules 1/1 modules 0 active           
*
*
 NG Live Development Server is running on http://localhost:4200.
*
5134ms building modules                                                                   
13ms sealing
0ms optimizing 
0ms basic module optimization 
43ms module optimization
1ms advanced module optimization 
9ms basic chunk optimization        
0ms chunk optimization 
1ms advanced chunk optimization 
0ms module and chunk tree optimization 
89ms module reviving
2ms module order optimization 
3ms module id optimization 
4ms chunk reviving 
0ms chunk order optimization 
19ms chunk id optimization
19ms hashing
0ms module assets processing 
56ms chunk assets processing
3ms additional chunk assets processing 
0ms recording 
0ms additional asset processing 
131ms chunk asset optimization
1059ms asset optimization
22ms emitting
Hash: 101774096aac67c140a7
Version: webpack 2.1.0-beta.18
Time: 6621ms
              Asset       Size  Chunks             Chunk Names
     main.bundle.js    3.75 MB    0, 2  [emitted]  main
polyfills.bundle.js     232 kB    1, 2  [emitted]  polyfills
          inline.js    4.96 kB       2  [emitted]  inline
           main.map    4.42 MB    0, 2  [emitted]  main
      polyfills.map     295 kB    1, 2  [emitted]  polyfills
         inline.map    5.13 kB       2  [emitted]  inline
         index.html  877 bytes          [emitted]  

Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.83 kB       0       
webpack: bundle is now VALID.

Now, when I make any changes to my code, it doesn't reload.

281330 avatar Aug 21 '16 04:08 281330

If you can provide us with a repo where this behaviour happens, we can investigate. Otherwise I'm not really able to reproduce this behaviour.

filipesilva avatar Aug 23 '16 14:08 filipesilva

I'm having same issue. My ng version is: angular-cli: 1.0.0-beta.11-webpack.2

ng serve works without live reload and ng build --watch only build the app and then quit without even serving the app on localhost

giovapanasiti avatar Sep 07 '16 00:09 giovapanasiti

I'm having the issue for directories starting with '+'. ng serve and ng build -w works normally: they build the application and wait for changes. If I modify a file in a 'normal' directory (i.e. app.component.ts), the change is detected and ng rebuilds. If I modify a file in a directory whose name starts with '+', nothing happens. However it's working when I use gedit: when gedit saves a file, it creates a backup that triggers the reload. Reloads also works if I manually create a new file.

osechet avatar Sep 08 '16 13:09 osechet

I renamed my directories to remove the '+' and in fact the problem happens with any subdirectory of app. If I modify anything directly inside src (i.e. index.html, main.ts, ...) reload works. If I modify something in a subdirectory of src (i.e. src/app/app.component.*, src/app/app.module.ts, src/assets, src/environments/environment.ts, ...) reload works as well. But if I modify something in a subdirectory of app (i.e. src/app/foo/foo.component.ts), there is no reload.

I'm on Ubuntu 14.04 and I can reproduce this with any repository. For example:

ng new project
cd project
ng g c foo
ng serve

Then open a browser on the application. Edit app.component.html as follow:

<h1>
  {{title}}
</h1>
<app-foo></app-foo>

Save: ng reloads the app.

Edit foo/foo.component.html as follow:

<p>
  foo works! ng reloads?
</p>

Save: ng does not reload.

@filipesilva Do you confirm you cannot reproduce following these steps?

osechet avatar Sep 09 '16 09:09 osechet

I had the same issue, but managed to fix it. The problem might have to do with folder naming. At first, my main project folder (where I would navigate to before doing "ng serve") was named something like "XX (Front)". I renamed it to "XX_Front" (and flattened the folder structure) and live reload started working.

FoodBuster avatar Sep 12 '16 06:09 FoodBuster

@osechet I followed your instructions and had a life reload be triggered when changing foo/foo.component.html.

I'm using beta.14 and VSCode as an editor, if that helps. Do you also get this in beta.14?

filipesilva avatar Sep 20 '16 02:09 filipesilva

I'm using vscode as well but I tested several editors to see if there was a difference. I'm not yet using beta.14. I will try during the week.

osechet avatar Sep 20 '16 07:09 osechet

I confirm the @FoodBuster naming problem. My project was in directory named like : c:\SomeDir\Some with space and (parenthesis)\myapp Reload was not triggered. Moving to : c:\AnotherDirectory And reload works.

AntoineViau avatar Sep 20 '16 12:09 AntoineViau

I'm on linux, the naming doesn't fix mine. My files are located at ~/git/my_codebase/ui/..., so no spaces or parentheses. Live reload not working. Changing to files like app.component.ts also don't trigger a reload.

dessalines avatar Sep 20 '16 17:09 dessalines

I fixed this by removing running rm -rf node_modules , and reinstalling angular-cli both globally and locally.

dessalines avatar Sep 21 '16 19:09 dessalines

I just updated my project from 1.0.0-beta.11-webpack.8 to 1.0.0-beta.15. Everything has been cleaned (node_modules, node cache...). Problem is still here.

I'm on Ubuntu 14.04.

osechet avatar Sep 22 '16 06:09 osechet

So as far as I can tell, there's two situations that can cause this issue:

  • a problem with folder paths having spaces, as described by @FoodBuster on https://github.com/angular/angular-cli/issues/1610#issuecomment-246259005
  • inotify reaching watcher max on linux, as described by and solved by @paillave on https://github.com/angular/angular-cli/issues/2389#issuecomment-250964095

We'll try to find a more permanent solution to these problems.

filipesilva avatar Oct 06 '16 15:10 filipesilva

@filipesilva I found the 3rd scenario where it doesn't live-reload - if you generate a component with the -component suffix; e.g.:

ng generate component title-component

mgol avatar Nov 08 '16 15:11 mgol

I can confirm doing ng serve doesn't watches for changes.

here is my ng --version log:

angular-cli: 1.0.0-beta.19-3
node: 6.9.1
os: linux x64

I am currently running Ubuntu 16.04

Whereas if I use the same files on my windows running system, changes appear fine.

If you wanna try out a repo just make a new app using ng new app-name

Try changing app.component.html file.

thesunnypro avatar Nov 08 '16 21:11 thesunnypro

I have greatly increased inotify limit and it resolved issue on Ubuntu 16.10

08.11.2016 22:11 "thesunnypro" [email protected] napisał(a):

I can confirm doing ng serve doesn't watches for changes.

here is my ng --version log:

angular-cli: 1.0.0-beta.19-3 node: 6.9.1 os: linux x64

I am currently running Ubuntu 16.04

Whereas if I use the same files on my windows running system, changes appear fine.

If you wanna try out a repo just make a new app using ng new app-name

Try changing app.component.html file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/1610#issuecomment-259260810, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB5UkzA73bY28URzFqs8RNrteKNADBBks5q8OV3gaJpZM4JgIZF .

Namek avatar Nov 08 '16 22:11 Namek