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

@wulfsberg explanation makes a lot of sense considering https://github.com/angular/angular-cli/issues/6238 (any file change in src/ triggers a rebuild).

filipesilva avatar May 10 '17 12:05 filipesilva

I'm consolidating https://github.com/angular/angular-cli/issues/5117 with this thread. If you're having this issue, make sure to check out #5117 for some more discussion (e.g. solution for vim users is listed there).

filipesilva avatar May 22 '17 11:05 filipesilva

Same thing here with Windows 7 and the most recent CLI.

Steps when starting from a directory with node_modules from a previous CLI install:

ng new hello-world --skip-install=true mklink /j "hello-world/node_modules" "./node_modules" cd hello-world ng build -aot -w

I then proceed to edit some html in src/app/app.component.html. The change is detected by doesn't appear in the browser.

Hash: aa73a2645a976a8ce9f8 Time: 3144ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {3} [initial] chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {3} [initial] chunk {2} main.bundle.js, main.bundle.js.map (main) 1.13 MB [initial] chunk {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

Without changing anything else in app.component.html I save again causing it to recompile and the changes are reflected:

Hash: ba4753ae6244f2bad1a8 Time: 3258ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {3} [initial] chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {3} [initial] chunk {2} main.bundle.js, main.bundle.js.map (main) 1.13 MB [initial] [rendered] chunk {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

I see the same behavior whether I use Visual Studio or Visual Studio Code.

edit: I'm pretty sure omitting the -aot switch fixes this so I'm using that as a temporary fix.

czimmons avatar May 22 '17 23:05 czimmons

Same issue here, it works with vim due to the tmp backup files but it fails with visual studio and atom.

I am using Arch Linux, node and angular version are posted below.

@angular/cli: 1.0.6 node: 7.10.0 os: linux x64 @angular/animations: 4.1.3 @angular/common: 4.1.3 @angular/compiler: 4.1.3 @angular/core: 4.1.3 @angular/forms: 4.1.3 @angular/http: 4.1.3 @angular/platform-browser: 4.1.3 @angular/platform-browser-dynamic: 4.1.3 @angular/router: 4.1.3 @angular/cli: 1.0.6 @angular/compiler-cli: 4.1.3

mrcl avatar May 31 '17 05:05 mrcl

i had same issue..i changed my directory name with no spaces and only letters..now it reload works fine

ipula avatar May 31 '17 07:05 ipula

Had this issue, my directory name had square brackets and spaces. Changed my directory name with no spaces then concatenated it with '-' and now it works.

cerinoligutom avatar Jun 09 '17 15:06 cerinoligutom

@alexsaraiva, ng server --poll=2000 worked. Thanks

dmalikcs avatar Jun 10 '17 11:06 dmalikcs

ng serve --poll=1000 works for me

lro3818 avatar Jun 29 '17 19:06 lro3818

Using ng server --aot has 1- change save lag: Save foo -> nothing Save bar -> foo Save foobar -> bar ...

--poll with any value is not working, changing folder name to simple is not working

Using ng-serve without --aot is working without problem Browser reload is not working- the sources are not correct served.

@angular/cli: 1.1.0 node: 6.11.0 os: win32 x64 @angular/animations: 4.2.5 @angular/common: 4.2.5 @angular/compiler: 4.2.5 @angular/core: 4.2.5 @angular/forms: 4.2.5 @angular/http: 4.2.5 @angular/platform-browser: 4.2.5 @angular/platform-browser-dynamic: 4.2.5 @angular/router: 4.2.5 @angular/cli: 1.1.0 @angular/compiler-cli: 4.2.5 @angular/language-service: 4.2.5

KrystianRos avatar Jul 07 '17 10:07 KrystianRos

@filipesilva Is there a chance to some fix in the near future? Maybe newer webpack version could fix that issues?

KrystianRos avatar Jul 11 '17 09:07 KrystianRos

@KrystianRos - Use ng serve --poll=1000 it works like a charm for below config:

"dependencies": {
    "@angular/animations": "^4.3.1",
    "@angular/cdk": "^2.0.0-beta.8",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.8",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.4.1",
    "zone.js": "^0.8.14"
  }

ghost avatar Jul 25 '17 15:07 ghost

Some issue, second change will be picked up: ng serve --poll=1000 or 5000 doesn't work for me.

When I remove the -aot flag it does work properly.

stefandroog avatar Aug 10 '17 08:08 stefandroog

I had problems on Ubuntu 16.04 with ng build --watch running once and quitting. Adding the --poll=1000 flag solved the issue, thanks @alexsaraiva

jhnoor avatar Sep 07 '17 07:09 jhnoor

Poll doesn't stop Webstorm from writing to .idea settings or Sourcetree from writing to the .git index. How do I stop ng serve from "recompiling" when these two things happen?

ghost avatar Oct 03 '17 21:10 ghost

When running ng build -w or ng serve, the reload only worked within the top directory "src" despite applying various fixes reported in this thread.

I was running

  • Linux 4.12.5-gentoo #2 SMP PREEMPT Sun Sep 17 10:24:52 EDT 2017 x86_64
  • node 8.4.0
  • npm 5.4.2
  • @angular/cli 1.4.5
  • fs.inotify.max_user_watches=524288
  • using dashes into filenames and directories (but no other fancy characters)
  • .angular-cli.json contained:
    {
      "apps": [
        {
          "root": "src",
          "outDir": "dist"
        }
      ]
    }
    

Upgrading @angular/cli resolved my issue: npm i @angular/[email protected] --save-dev

EricGravel avatar Oct 08 '17 21:10 EricGravel

See if any one is having this type of file name. I was having the same and I fixed it using this solution.

My folder was named as 'question' but when I imported it in app module, I did like this import { QuestionModule } from './Question/Question.module';

Notice in the path there is 'Q'. My code was running perfectly on browser but webpack stopped tracking my files. I changed it to import { QuestionModule } from './question/question.module';

And now webpack is also working

irfaan008 avatar Oct 12 '17 23:10 irfaan008

I used tip @thesunnypro and I had a solution

Tip: sudo echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf sudo sysctl -p /etc/sysctl.conf

My version CLI: @angular/cli: 1.4.9

My OS Fedora 23

xola139 avatar Nov 23 '17 18:11 xola139

After trying multiple options, I solved the issue by reinstalling nodes_modules. Hope it helps.

Steps

  • rm -rf nodes_modules/
  • npm update
  • npm install

cabaleirog avatar Dec 06 '17 14:12 cabaleirog

ng serve --poll=1000 works for me fine Thanks

sergiyvoytovych avatar Feb 03 '18 11:02 sergiyvoytovych

--poll=1000 saved me thanks !!

PapyElGringo avatar Feb 06 '18 10:02 PapyElGringo