question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng serve produces error randomly

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0
node: 6.10.1
os: linux x64
@angular/animations: 4.0.0
@angular/cli: 1.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/compiler-cli: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/platform-server: 4.0.0
@angular/router: 4.0.0
@ngtools/webpack: 1.3.0

Repro steps.

    ng serve

The log given by the failure.

Module build failed: Error
    at WebpackCompilerHost.populateWebpackResolver (/home/bunyamin/WebstormProjects/c3dp/node_modules/@ngtools/webpack/src/compiler_host.js:135:51)
    at _donePromise.Promise.resolve.then.then.then.then.then (/home/bunyamin/WebstormProjects/c3dp/node_modules/@ngtools/webpack/src/plugin.js:366:32)
    at process._tickCallback (internal/process/next_tick.js:109:7)
 @ ./src/app/patient/patient-care-plan/index.ts 2:0-105
 @ ./src/app/patient/patient.module.ts
 @ ./src async
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

Desired functionality.

The project does not contain any error and works well. However, it gives the error above when it recompiled at some random moments.

Mention any other details that might be useful.

The most obvious example of this bug: I was working on my project (there were no errors) and I added just a comment like // some comment and it gave the error when recompiled. Then, I stopped and re-run the ng serve command and there were no error this time.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:25 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
isaacplmanncommented, Apr 12, 2017

I’m getting the same error. It only happens for me when I save a file that’s in a lazy loaded module. If I then save the app.component.ts file, the build succeeds (without needing to kill the process and restart). I haven’t been able to reproduce with a demo app though.

4reactions
scott-phillips-spcommented, Jul 7, 2017

I looked into this problem and I believe it is a race condition between the invalidating & read files for the host compilation. As a project grows bigger the chance of the race condition increase. I tried to make a reproduction using a fresh app and tried with 10 components, but that wasn’t enough to reproduce the issue.

The issue is that there is a race condition invalidating a file:

Files will get invalidate here from a watch conidition: https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/src/plugin.ts#L273

They will get re-read here from the ngloader: https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/src/loader.ts#L454

However, if in between these two points the populateWebpackResolver is called it fail because the invalidate command removes the file from the cache. https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/src/compiler_host.ts#L149

I created a pull request that works for me locally with my app. It makes the change that when a file changes instead of removing it from the cache and waiting for the loader to re-load the file it will immediately re-read the changes and populate the cache. https://github.com/angular/angular-cli/pull/6920

Read more comments on GitHub >

github_iconTop Results From Across the Web

When running ng serve -o I'm getting an error - Stack Overflow
When I run the ng serve -o command I get the following error, and I have tried everything...deleting the node_modules folder and ...
Read more >
Identify and Fix Build and Deployment Errors in Your Angular ...
Many common build errors may occur as a result of rebuilding your app while using ng serve or running ng build or ng...
Read more >
Angular CLI - codecraft.tv
Create a Build with ng build ... The ng serve command does a great job of enabling development locally. However eventually we will...
Read more >
Solved: Angular - Invalid version: "15.2-15.3"
Whilst working on a new Angular project I recently came across an unusual error when trying to build a new project generated through...
Read more >
Why your Angular App is not Working: 11 common Mistakes
To resolve the problem, you need to import the missing module into your module. Most of the cases, that module would be the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found