1

When I compile my app with

ng build --prod

I have this error

ERROR in : Cannot determine the module for class AppComponent in D:/desarrollos/PatientPortal/front/src/app/customizations/database/app.component-database.ts! Add AppComponent to the NgModule to fix it.

but if it compile with

ng build --configuration=prod

It's compile ok and my app works ok.

I see the difference is the first one is compile with the AOT option, but I don't know why have this error, and don't know if it is important (maybe is about an extended class I have, but is important to me). Can you help me?

Ulises 2010
  • 478
  • 1
  • 6
  • 16
  • In which module did you declare that `AppComponent`? And don't confuse it with the default `AppComponent`. Maybe show your component declaration from `/app.component-database.ts` – David Jun 26 '20 at 08:44
  • I have the default AppComponent and duplicate it to use a different app.component.html (need a costumization) and replace it in the angular.json... but I don't declare because one substitute the other – Ulises 2010 Jun 26 '20 at 08:51
  • If just the html changes, try keeping the same component and just substituting the html in `angular.json`. – David Jun 26 '20 at 09:00
  • Thanks a lot, I do it, because in this case actually don't use the .ts file, but have other error `ERROR in : Cannot determine the module for class BookappointmentsComponent in D:/desarrollos/PatientPortal/front/src/app/customizations/database/bookappointments.page-database.ts! Add BookappointmentsComponent to the NgModule to fix it.` and in this case I use this .ts file – Ulises 2010 Jun 26 '20 at 09:57
  • The problem here is that `BookappointmentsComponent` is not referenced in any NgModule. See: https://stackoverflow.com/questions/47119135/cannot-determine-the-module-for-component-angular-5/47124835 – A. Agius Jul 01 '20 at 12:32

2 Answers2

1

Angular normally complains when you declare a component that is not part of any module.

If you just want to modify the default AppComponent html template at build time, you can just create a separate html template and use fileReplacements feature from angular.json.

David
  • 33,444
  • 11
  • 80
  • 118
  • Thanks a lot, I do it, because in this case actually don't use the .ts file, but have other error ERROR in : Cannot determine the module for class BookappointmentsComponent in D:/desarrollos/PatientPortal/front/src/app/customizations/database/bookappointments.page-database.ts! Add BookappointmentsComponent to the NgModule to fix it. and in this case I use this .ts file – – Ulises 2010 Jun 29 '20 at 10:45
0

I found help In the github repository:

https://github.com/angular/angular/issues/38070

In my case, I'm trying to compile and abstract class using @Component decorator insteed @Directive decorator.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ulises 2010
  • 478
  • 1
  • 6
  • 16