
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
While Upgrading the angular version or during the ng serve we might have seen the below error related to NgModule.imports such as “error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class”.
Ex: “ERROR in node_modules/ng-pick-datetime/date-time/adapter/moment-adapter/moment-date-time.module.d.ts:3:22 – error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.”
Solution 1:
This likely means that the library (ng-pick-datetime/date-time/adapter/moment-adapter/moment-date-time.module) which declares OwlMomentDateTimeModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy.
Check if a newer version of the library is available, and update if so. Also consider checking with the library’s authors to see if the library is expected to be compatible with Ivy.
Solution 2:
Sometimes it can be resolved by restarting the server, because your module is not yet loaded by the Angular Server in node
ng serve
, so restart your server so the server loads the module that you just added in @NgModule app.module.ts
.
Sometimes when you change/update @NgModule in your project, projects get compiled but changes doesn’t get reflect. So, restart once to get expected results if you not get it. ng serve
Solution 3:
It can be fixed by opting out of Ivy as per documentation.
Change tsconfig.app.json to opt out of Ivy.
"enableIvy": false
Solution 4:
Try to clear cache
npm cache clean --force
npm install
Contact us at info@codingskool.in for any coding related help.
happy coding !