Angular-cli: Improve error message in AOT webpack plugin if AOT compile fails

Created on 7 Jul 2017  路  7Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.


ngtools/webpack: 1.4.2

Repro steps.


Use AOT plugin with webpack, and write code that does not compile.

The log given by the failure.


Module not found: Error: Can't resolve './../../aot/my-app/src/app/app.module.ngfactory'

Desired functionality.


The above error message happens because AOT compilation fails and app.module.ngfactory is not created. The plugin should log AOT compilation errors to console.

Also my webpack build hangs and does not exit with an error when this happens. Unsure if that issue is specific to me, or a general issue that can be fixed in the plugin.

Mention any other details that might be useful.


My quick fix was to add a catch here and log the error to console.

2 (required) inconvenient

Most helpful comment

For everyone struggling with this, here's a temporary workaround I came up with to get the full errors.

In your project, open the file node_modules\@ngtools\webpack\src\plugin.js
Add the following to the end of line 374: .catch(e => console.error(e))

Now you'll get the REAL error message :smile:

All 7 comments

@Brocco @filipesilva I believe this ticket should be upgraded in priority. I spent several hours today trying to figure out why AOT build was failing. Ultimately it was the same issue as https://github.com/angular/angular-cli/issues/7113. Looks like many developers struggled today with this cryptic error message.

Referencing a similar feature request that came in yesterday. https://github.com/angular/angular-cli/issues/7126

Absolutely this needs to be supported. Its maddening to try and figure out which part of my code broke AOT -- and the only way to do it is to incrementally removing parts of my app.

For everyone struggling with this, here's a temporary workaround I came up with to get the full errors.

In your project, open the file node_modules\@ngtools\webpack\src\plugin.js
Add the following to the end of line 374: .catch(e => console.error(e))

Now you'll get the REAL error message :smile:

Thanks @PachowStudios ! I was having a hard time trying to find the real error 馃

Thanks for reporting this issue. This issue was originally reported a long time ago and since then we've had many releases, one of which might have addressed this problem. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gotschmarcel picture gotschmarcel  路  3Comments

NCC1701M picture NCC1701M  路  3Comments

jbeckton picture jbeckton  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

naveedahmed1 picture naveedahmed1  路  3Comments