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 build --aot not reporting where the errors are

See original GitHub issue

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No

Description

ng build --aot reports an error in a html template, but does not state in which template file

πŸ”¬ Minimal Reproduction

I have created the sample project here

clone and run ng bulid --aot

πŸ”₯ Exception or Error

Expected output when running ng bulid --aot


...
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]

ERROR in : 'test-component' is not a known element:
1. If 'test-component' is an Angular component, then verify that it is part of this module.
2. If 'test-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<div style="text-align:center">
  [ERROR ->]<test-component></test-component>
</div>")

test-component is part of the test-module which is not imported in the app module, the error is correct but nowhere in the error states that the problem is in app.component.html:3

In a project with dozen of template files is quite hard to pinpoint where the error is.

🌍 Your Environment


Angular CLI: 7.3.9
Node: 10.14.2
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cli                      7.3.9
@ngtools/webpack                  7.3.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0

Anything else relevant? running ng build in git bash for windows

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mgechevcommented, Jun 27, 2019

Looks like this is a compiler issue. @alan-agius4 / @clydin we should probably transfer to angular/angular?

1reaction
pakopacommented, Jun 26, 2019

info like app.component.html:3 should be useful too

I submitted this issue because I think this information is also crucial. Now it is only reporting the kind of error (that part is correct and with a great level of detail) but not where that error is. If I am using a custom component across dozens of templates, locating the one producing the error requires searching the output text across the whole project (current workaround). The build tools should make our life easier, not harder.

BTW, thank you for testing and confirming that this happens in v8 too

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular ng build --prod not throwing errors in code (but ...
If I build with ng build --prod the app is build nice and pretty - no errors or warnings or anything though we...
Read more >
AOT metadata errors - Angular
The following are metadata errors you may encounter, with explanations and suggested corrections. Expression form not supported
Read more >
The Ahead-of-Time (AOT) compiler - Angular - w3resource
The AOT compiler detects and reports template binding errors during the build step before users can see them. Better security. AOT compiles HTMLΒ ......
Read more >
Angular 9's Best Hidden Feature: Strict Template Checking
We only had to run ng build to see this error with Angular 9, while in Angular 8 we did not see this...
Read more >
ng build fails if AOT is enabled (Angular 11) - DayPilot Forums
This likely means that the library (daypilot-pro-angular) which declares DayPilotModule has not been processed correctly by ngcc, or is not compatible withΒ ...
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