Angular 12 migration issue error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

Viewed 2384

We are migrating our project to angular 12 and primeng 12, but we are stuck in this error that repeat it many times. We looked at other similar questions but couldn´t resolve with any of the solutions proposed on the answers.

When do ng build it shows this error:

Error: src/app/app-shared.module.ts:117:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

export class AppSharedModule {}

and is followed by many repeated errors in the same location.

enter image description here

We already tried many solutions like do ng server, deactivate Ivy, but none of them solved.

Is there any solution for this? Thanks!

2 Answers

To answer the question, we came to a conclusion that we made a mistake trying to migrate our project from angular 10 to 12 and prime ng 9 to 12.

When migrating an angular project, is not recomended upgrade multiple versions at the same time

As angular recomends in https://angular.io/guide/updating

So,now will make the migration step by step, first preparing the application, by removing all warnings and deprecated, and then migrating one version at a time.

Thanks!

Edit: After restart migration this error appears aggain after set "enableIvy": true as one of our modules is not compatible with ivy, setting to false solve the problem

Had this problem because one of the modules had a bundled package files inside. Had to remove it and add a proper package.json reference.

Related