Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack rebuild error #4326

Closed
digital216 opened this issue Feb 1, 2017 · 21 comments · Fixed by #4334
Closed

Webpack rebuild error #4326

digital216 opened this issue Feb 1, 2017 · 21 comments · Fixed by #4334

Comments

@digital216
Copy link

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.
@born2net
Copy link

born2net commented Feb 1, 2017

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

@diicar
Copy link

diicar commented Feb 1, 2017

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

@born2net
Copy link

born2net commented Feb 1, 2017

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

@johannesjo
Copy link

johannesjo commented Feb 1, 2017

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

@trevor-hackett
Copy link

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

@intellix
Copy link
Contributor

intellix commented Feb 1, 2017

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

@born2net
Copy link

born2net commented Feb 1, 2017

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/[email protected]

until .28 gets stable

@web-dave
Copy link

web-dave commented Feb 1, 2017

@born2net I'll try it out

@johannesjo
Copy link

johannesjo commented Feb 1, 2017

npm install --save @ngtools/[email protected] 

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

@web-dave
Copy link

web-dave commented Feb 1, 2017

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

@alshdavid
Copy link

alshdavid commented Feb 2, 2017

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..

@web-dave
Copy link

web-dave commented Feb 2, 2017

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

@Sviatique
Copy link

The same thing with beta.30

@alshdavid
Copy link

alshdavid commented Feb 8, 2017

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.

@rickardd
Copy link

npm install --save @ngtools/[email protected]

Worked for me too! yay

@emreavsar
Copy link

emreavsar commented Mar 7, 2017

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.

@emreavsar
Copy link

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"
  ]
}

@mhadaily
Copy link
Contributor

mhadaily commented Apr 15, 2017

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/[email protected]

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

@zinderud
Copy link

zinderud commented Nov 17, 2017

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

@emreavsar
Copy link

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

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.