Skip to content

Webpack rebuild error #4326

Closed
Closed

Description

@digital216

OS?

Ubuntu 16.04

Versions

angular-cli: 1.0.0-beta.28.3
node: 7.4.0
os: linux 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

Repro steps.

Created the app with the angular-cli (ng new). Ran ng serve to make sure everything was working. All was good, webpack worked and reported:

Hash: 7a95e8c73d53b9f210c7                    
Time: 8041ms
chunk    {0} main.bundle.js, main.bundle.map (main) 17.2 kB {3} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 205 kB {4} [initial] [rendered]
chunk    {2} scripts.bundle.js, scripts.bundle.map (scripts) 375 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.83 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.

I was able to load the app in a browser. Made a small change to the app.component.ts file (removed the trailing new line). Saved the file, webpack attempted to re-bundle the file, but failed.

The log given by the failure.

Hash: 7a95e8c73d53b9f210c7                
Time: 613ms
chunk    {0} main.bundle.js, main.bundle.map (main) 17.2 kB {3} [initial]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 205 kB {4} [initial]
chunk    {2} scripts.bundle.js, scripts.bundle.map (scripts) 375 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.83 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]

ERROR in Cannot read property 'length' of undefined
webpack: Failed to compile.

Activity

  1. born2net commented on Feb 1, 2017

    @born2net

    same issue, works fine on first build, subsequent builds fail.

    ERROR in ./src/app/campaigns/sequencer.ts
    Module build failed: Error
        at WebpackCompilerHost.populateWebpackResolver (C:\msweb\studioweb\node_modules\@ngtools\webpack\src\compiler_host.js:218:51)
        at C:\msweb\studioweb\node_modules\@ngtools\webpack\src\plugin.js:352:33
        at process._tickCallback (internal/process/next_tick.js:103:7)
     @ ./src/app/campaigns/index.ts 26:0-40
     @ ./src async
     @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
     @ ./~/@angular/core/src/linker.js
     @ ./~/@angular/core/src/core.js
     @ ./~/@angular/core/index.js
     @ ./src/main.ts
     @ multi webpack-dev-server/client?http://localhost:4208/ ./src/main.ts
    webpack: Failed to compile.
    

    versions

    angular-cli: 1.0.0-beta.28.3
    node: 6.9.5
    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/language-service: 2.4.5
    @angular/platform-browser: 2.4.5
    @angular/platform-browser-dynamic: 2.4.5
    @angular/router: 3.2.1
    @angular/compiler-cli: 2.4.5
    
    
  2. diicar commented on Feb 1, 2017

    @diicar

    Same issue ... :(
    rebuilld is too fast 🥇 thank you ;)

  3. born2net commented on Feb 1, 2017

    @born2net

    I agree, I started crying from joy of how fast it was... but started crying again when it crashed

  4. johannesjo commented on Feb 1, 2017

    @johannesjo

    Same here on ubuntu 16.10 and node 6.9.2.

    Happens with ng-cli
    1.0.0-beta.22-1
    1.0.0-beta.24
    1.0.0-beta.26
    1.0.0-beta.28

  5. trevor-hackett commented on Feb 1, 2017

    @trevor-hackett

    I may be wrong, but I believe it may have to do with the fact that the typescript doesn't get compiled, or at least compiled correctly after the first initial build. See my other comment

  6. intellix commented on Feb 1, 2017

    @intellix
    Contributor

    I'm getting the same issue and have been debugging a little. Not found anything yet but here's an example project: https://github.com/intellix/angular-cli-b28/tree/master/src/app/lazy

    I only have the problem when saving lazy SCSS or HTML. Saving a TS doesn't give Module build failed: error though

  7. born2net commented on Feb 1, 2017

    @born2net

    ok I reverted back to .26 so I can work for now but that was not enough.
    I also had to:

    
    npm install --save @ngtools/webpack@1.2.4
    
    

    until .28 gets stable

  8. web-dave commented on Feb 1, 2017

    @web-dave

    @born2net I'll try it out

  9. johannesjo commented on Feb 1, 2017

    @johannesjo
    npm install --save @ngtools/webpack@1.2.4 
    

    That's it! Works also with the new version (.28).

  10. web-dave commented on Feb 1, 2017

    @web-dave

    pew, have to do a workshop tomorrow. saved my day/night

  11. added 2 commits that reference this issue on Feb 2, 2017
    3c5418d
    fda15e6
  12. added a commit that references this issue on Feb 2, 2017
    9afaa3a
  13. alshdavid commented on Feb 2, 2017

    @alshdavid

    I have this problem.

    Windows 10
    Node 6.9.5

    running ng serve
    When I change an HTML file it throws in cmd:
    ERROR in ./src/app/components/side-menu/side-menu.component.html Module build failed: Error at WebpackCompilerHost.populateWebpackResolver (C:\sandbox\admin.marshallinstalls.co.nz\node_modules\@ngtools\webpack\src\compiler_host.js:218:51) at C:\sandbox\admin.marshallinstalls.co.nz\node_modules\@ngtools\webpack\src\plugin.js:352:33 at process._tickCallback (internal/process/next_tick.js:103:7) @ ./src/app/components/side-menu/side-menu.component.ts 21:22-59 @ ./src/app/app.module.ts @ ./src/main.ts @ multi main

    However when I run ng serve --aot it compiles and runs just fine

    EDIT: work just fine - for a time. After 6 reloads it gave me the same error as before..

  14. web-dave commented on Feb 2, 2017

    @web-dave

    beta 29 has the same error, but the fix doesn't work!!

  15. Sviatique commented on Feb 8, 2017

    @Sviatique

    The same thing with beta.30

  16. alshdavid commented on Feb 8, 2017

    @alshdavid

    I have updated to node 7.5 + cli beta.30 (from 6.9.5 & beta.28) and it seems the problem is no longer present.

    I also ran an ng upgrade on the project, though I don't think that would have had an affect.

  17. added a commit that references this issue on Feb 9, 2017
    a856f51
  18. rickardd commented on Feb 22, 2017

    @rickardd

    npm install --save @ngtools/webpack@1.2.4

    Worked for me too! yay

  19. emreavsar commented on Mar 7, 2017

    @emreavsar

    anybody facing this issue "@angular/cli": "^1.0.0-rc.0" in package.json?

    My steps to reproduce:

    1. start the app with ng serve -> 👍 works
    2. go into a lazy loaded module's code and just drop some new lines somewhere, so that livereload kicks in
    3. face the error 👎
    Failed to compile.
    ./src/app/home/signup/personal-gln-form/personal-gln-form.component.ts
    Module build failed: Error
        at WebpackCompilerHost.populateWebpackResolver (/Users/emre/projects/eviprev-it/eviprev-dossier-frontend/node_modules/@ngtools/webpack/src/compiler_host.js:135:51)
        at _donePromise.Promise.resolve.then.then.then.then (/Users/emre/projects/eviprev-it/eviprev-dossier-frontend/node_modules/@ngtools/webpack/src/plugin.js:327:32)
        at process._tickCallback (internal/process/next_tick.js:103:7)
     @ ./src/app/home/signup/signup.module.ts 17:0-91
     @ ./src async
     @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
     @ ./~/@angular/core/src/linker.js
     @ ./~/@angular/core/src/core.js
     @ ./~/@angular/core/index.js
     @ ./src/main.ts
     @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
    

    Note: This issue does not happen, when doing the same in a non lazy module.
    Note 2: i have no @ngtools/webpack in my package.json at all.

  20. emreavsar commented on Mar 7, 2017

    @emreavsar

    I did some research based on my problem, maybe it helps someone else as well:

    i introduced typings into the project, and since I did this, this problem happens with the live-reload of lazy loaded modules. No idea why this happens.

    Maybe someone can give a brief info about this?

    I'm using the oldschool way of typings as follows:

    package.json:

    {
      "scripts": {
        ...
        "install": "typings install"
      }
    ...
      dependencies: {
    ...
        "typings": "^2.1.0",
    ...
      }
    }
    

    typings.json:

    {
      "globalDependencies": {
        "typings": "github:t4deon/FHIR-STU3-TS-Typings/typings.d.ts#e36b4cf4bb07734b97ea8d14893f7747fd990438"
      }
    }
    

    src/tsconfig.app.json:

    ...
    {
      "files": [
        "../typings/index.d.ts"
      ]
    }
    
  21. mhadaily commented on Apr 15, 2017

    @mhadaily
    Contributor

    I know this topic is closed, but when we search on Google this is the first result and I hope it helps whoever comes to this page and see the last comment.

    this works for me

    yarn add @ngtools/webpack@1.3.0

    ng details:
    @angular/cli: 1.0.0
    node: 7.9.0
    os: darwin x64

    @angular/common: 4.0.2
    @angular/compiler: 4.0.2
    @angular/core: 4.0.2
    @angular/forms: 4.0.2
    @angular/http: 4.0.2
    @angular/platform-browser: 4.0.2
    @angular/platform-browser-dynamic: 4.0.2
    @angular/router: 4.0.2
    @angular/cli: 1.0.0
    @angular/compiler-cli: 4.0.2
    @ngtools/webpack: 1.3.0
    
  22. zinderud commented on Nov 17, 2017

    @zinderud

    hocam su adresde #4326 da birkaç kişi sorun yaşamış
    yarn add @ngtools/webpack@1.3.0 ile biri sorunu çözmüş şimdiki güncel i
    yarn add @ngtools/webpack@1.8.2 bir denermisiniz

  23. emreavsar commented on Nov 17, 2017

    @emreavsar

    @zinderud bende problem cözüldü bile aga

  24. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  25. locked and limited conversation to collaborators on Sep 7, 2019
  26. added a commit that references this issue on May 29, 2026
    5fb1ea3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions