-
Notifications
You must be signed in to change notification settings - Fork 12k
"ng build" showing "ERROR in No NgModule metadata found for 'AppModule'" instead of detailed root errors #18424
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
Comments
Hi @feng-xiao, I did try to replicate issue but I wasn't with the snippet provided above. Can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via That being said, it is expected that in JIT mode (AOT false) errors are less accurate and/or certain errors are not reported. Read more: https://angular.io/guide/aot-compiler#how-aot-works |
Hi @alan-agius4, Is there a setting that can output the root errors? |
Hi @feng-xiao, I am not following what you mean by setting to output the root errors. When not using AOT, the application is compiled using TSC (TypeScript compiler) which cannot emit Angular related synthetic and semantical errors. |
Hi @alan-agius4 , I've spent couple days to figure out why I kept getting error "ERROR in No NgModule metadata found for 'AppModule'". I finally found the root cause yesterday by debugging the 'ng build' in VS Code debugger. At the beginning, I even didn't realize the error is related to the flag AOT=true. I think the Angular CLI should have a way to emit/report the root errors even when TSC is being used on JIT mode. So developers don't need to spend days to figure it out. If it's not easy for the team to report errors under TSC, I think the message should be revised to be more helpful, e.g. instruct developer to switch to AOT mode to show the root errors that cause "ERROR in No NgModule metadata found for 'AppModule'". In my case, the root error 'Lambda used in routing' is only happening on JIT mode, AOT accepts the format. So we still need a mean to report the errors in JIT mode. When I debugged the issue, I saw the root error (Lambda method not allowed) is stored in structuralDiagnostics, and it's not reported in JIT mode. |
@feng-xiao, both of the above errors are reporting by the Angular Compiler, likely it’s failing when trying to load lazy loading routes. Can you share a reproduction in how to replicate the error?
Since version 9 AOT is the default for development builds, for both new and existing application. |
Hi @alan-agius4 , I've uploaded my code to https://github.com/feng-xiao/angular-issues-no-metadata-found. You can follow the instructions below to reproduce the error.
|
Hi @feng-xiao, The issue seems to be caused because you are using the See: angular/angular#31893 (comment) and https://angular.io/guide/angular-compiler-options#strictmetadataemit |
Hi @alan-agius4 , great! Thank you very much for looking into my issues and pointing me to the correct cause! Really appreciate it! |
`strictMetadataEmit` option which is not intended to be used for applications. See: https://angular.io/guide/angular-compiler-options#strictmetadataemit Closes #18424
`strictMetadataEmit` option which is not intended to be used for applications. See: https://angular.io/guide/angular-compiler-options#strictmetadataemit Closes #18424
Regarding the
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
`strictMetadataEmit` option which is not intended to be used for applications. See: https://angular.io/guide/angular-compiler-options#strictmetadataemit Closes angular#18424
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, the previous version in which this bug was not present was: ....Description
In JIT build mode (AOT=false), "ng build" keeps reporting "ERROR in No NgModule metadata found for 'AppModule'" instead of showing detailed root issues - Lambda not supported in 'app-routing.module.ts'
🔬 Minimal Reproduction
Root issue - app-routing.module.ts
🔥 Exception or Error
The error caught during grabbing AppModule's metadata. In the error details, it says the error will be reported, but it didn't. Without debugging, I only see error 'ERROR in No NgModule metadata found for 'AppModule' reported by Angular CLI.

🌍 Your Environment
Anything else relevant?
tsconfig.json
The text was updated successfully, but these errors were encountered: