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

Browser does not refresh after code changed

Open web-dave opened this issue 9 years ago • 21 comments

angular-cli: 1.0.0-beta.28.3 node: 6.9.2 os: win32 x64 @angular/common: 2.4.5 @angular/compiler: 2.4.5 @angular/core: 2.4.5 @angular/forms: 2.4.5 @angular/http: 2.4.5 @angular/platform-browser: 2.4.5 @angular/platform-browser-dynamic: 2.4.5 @angular/router: 3.4.5 @angular/compiler-cli: 2.4.5

ng serve code change webpack: Compiling... Hash: 228604d16756d5a0fdd3 Time: 717ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial] chunk {1} main.bundle.js, main.bundle.map (main) 3.97 kB {3} [initial] chunk {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.64 MB [initial] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] webpack: Compiled successfully.

browser don't refresh. do not solve the problem rerun ng serve => change available

web-dave avatar Feb 01 '17 22:02 web-dave

That's weird I just created a new project with 1.0.0-beta.28.3 and it is refreshing just fine.

trevor-hackett avatar Feb 01 '17 22:02 trevor-hackett

Yes. I just did a npm i -g angular-cli and ng new bla

web-dave avatar Feb 01 '17 22:02 web-dave

I double checked it already

And I restarted my machine

web-dave avatar Feb 01 '17 22:02 web-dave

I can confirm. When editing the typescript it doesn't refresh. If you update the template, it refreshes.

trevor-hackett avatar Feb 01 '17 23:02 trevor-hackett

I just unistalled it and reinstall it so I'll go back to previous, have to do a workshop tomorrow and need cli :(

web-dave avatar Feb 01 '17 23:02 web-dave

Looks like the typescript isn't getting compiled. I edit the typescript (introduce a function) and adjusted the template so that it would refresh. The new function doesn't get called (when clicking on a button to trigger the method) after the page refresh.

Instead get an error saying that the function doesn't exist.

Stopping ng serve and restarting it will recompile the typescript and suddenly the function exists.

trevor-hackett avatar Feb 01 '17 23:02 trevor-hackett

Same issue here. I just tried uninstalling/reinstalling everything and running ng update, no change. Still seeing old .ts code until I stop and restart ng serve

joshorvis avatar Feb 01 '17 23:02 joshorvis

Can you try npm install --save @ngtools/[email protected] to see if that fixes the issue?

beeman avatar Feb 01 '17 23:02 beeman

Thx, that's it.

web-dave avatar Feb 01 '17 23:02 web-dave

@beeman - that worked for me too, thanks!

joshorvis avatar Feb 02 '17 00:02 joshorvis

I have the same issue with beta 29. This time it doesn't solve to install ngtools/webpack

web-dave avatar Feb 02 '17 07:02 web-dave

A late comment from a newbie.

Using Angular 4.0.2, it seems that the 'rebuild on change' does not work if the project path contains '('. Potentially other legal characters could also have this impact.

nisserne avatar Apr 19 '17 07:04 nisserne

I am facing the same problem now. @angular/cli: 1.2.0 It detect the changes on .ts and html files, it says that it's compiling, the browser refreshes but nothing change. I can delete everything from many .ts files and it don't even show an error. Only way to see the changes is stopping and ng serve again

adrianolsk avatar Jun 30 '17 01:06 adrianolsk

I have noticed this on VS2017 15.7.1 ,dotnet core 2.1 and Angular/Angular-CLI ^6.0.3

(I removed webpack from packages completely - The angular add new does not use it so I nuked it too based on the dotnet core 2 template based on angular 5 (not the dot net core 1 template based on angualr 4))

  • It was not refreshing my page from VS but when I did a ng serve it worked as expected.
  • I noticed in VS that even on refreshing and I made changes they did not appear.
    • http://localhost:63294/
  • I looked in the output for ASP.NET Core Web Server
    • ** Angular Live Development Server is listening on localhost:50273, open your browser on http://localhost:50273/ **
    • This WAS not the port VS studio opened for me
    • When I went to this PORT it was changing fine

I realised it was serving an old build for some reason. Where does dotnet core serve build from? the /dist directory obviously. I deleted everything in the /dist directory. Refreshed the page on the port VS gave me and bam! It started working again with auto rebuild and auto refresh.

I think if something is in the dist folder then dotnet will NOT proxy to the CLI server. Make sure its clean

p10tyr avatar May 23 '18 12:05 p10tyr

@ppumkin I have this issue too. This needs to be reported to Microsoft.

kilanny avatar Aug 16 '18 08:08 kilanny

@ibraheemalkilanny Turning on the "Disable cache (while DevTools is open)" setting in the Chrome Developer Tools (F12 to open Dev Tools, then F1 to open settings page) resolved the issue for me.

apoblock avatar Aug 20 '18 20:08 apoblock

I was having the same issue, I resolved my issue by:

  • Updating all NuGet packages (I was running things in Visual Studio).

  • Updating all packages via ng update --all (that is if you are lucky), I had to update the core first and then find my way trough the rest.

  • Then I do a ng build --prod because some issues are only discovered then.

  • Then an ng serve (I think this is not necessary)

  • Delete the files from the dist folder

Hypenate avatar Aug 22 '18 16:08 Hypenate

I have noticed this on VS2017 15.7.1 ,dotnet core 2.1 and Angular/Angular-CLI ^6.0.3

(I removed webpack from packages completely - The angular add new does not use it so I nuked it too based on the dotnet core 2 template based on angular 5 (not the dot net core 1 template based on angualr 4))

  • It was not refreshing my page from VS but when I did a ng serve it worked as expected.
  • I noticed in VS that even on refreshing and I made changes they did not appear.
    • http://localhost:63294/
  • I looked in the output for ASP.NET Core Web Server
    • ** Angular Live Development Server is listening on localhost:50273, open your browser on http://localhost:50273/ **
    • This WAS not the port VS studio opened for me
    • When I went to this PORT it was changing fine

I realised it was serving an old build for some reason. Where does dotnet core serve build from? the /dist directory obviously. I deleted everything in the /dist directory. Refreshed the page on the port VS gave me and bam! It started working again with auto rebuild and auto refresh.

I think if something is in the dist folder then dotnet will NOT proxy to the CLI server. Make sure its clean

Hi, This workaround worked perfecte for me!

rodrigoporcionato avatar Oct 15 '18 14:10 rodrigoporcionato

I have this issue too.

id1945 avatar Nov 07 '18 17:11 id1945

For me it's when I edit component styles (*.scss) that it won't refresh. @angular/cli": "^7.3.9 @ngtools/[email protected]

svassr avatar May 16 '19 21:05 svassr