2

I've searching for an answer but could not find any solution that fix the issue.

I have updated version of Angular from version 8 to version 9. Everything worked fine on 8 but after update app does not compile due to error

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

But this module doe not contain any errors. It's clean as it was in version 8 when it worked. I tried different things:

  1. remove node_modules and re-install packages
  2. close terminal and re-open
  3. close editor(VSC) and re-open
  4. clean cache npm cache clean with and without --force flag
  5. "importHelpers": true, in tsconfig.json file

Components are in declarations, modules in imports, everything is correct and groups.module.ts shows error but file does not contain any errors inside. Modules are imported correctly as well (i.e. import { MatPaginator } from '@angular/material/paginator'; when in version 8 was import { MatPaginator } from '@angular/material'; so regarding those things it is as it's been.

The only thing that helped was disabling Ivy with: "angularCompilerOptions": {"enableIvy": false } but it's pointless to update application if I cannot use improvements.

My package.json file:

"dependencies":{
"@angular-devkit/build-webpack": "~0.901.15",
"@angular/animations": "^9.1.13",
"@angular/cdk": "^9.0.1",
"@angular/common": "~9.1.13",
"@angular/compiler": "~9.1.13",
"@angular/core": "~9.1.13",
"@angular/forms": "~9.1.13",
"@angular/material": "^9.0.1",
"@angular/platform-browser": "~9.1.13",
"@angular/platform-browser-dynamic": "~9.1.13",
"@angular/router": "~9.1.13",
"@ng-bootstrap/ng-bootstrap": "^5.1.1",
"@ngrx/effects": "^8.1.0",
"@ngrx/schematics": "^8.1.0",
"@ngrx/store": "^8.1.0",
"@ngrx/store-devtools": "^8.1.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"npm": "^6.12.0",
"resize-observer-polyfill": "^1.5.1",
"rxjs": "^6.6.7",
"tslib": "^1.10.0",
"webpack": "^4.46.0",
"webpack-dev-server": "^3.11.3",
"zone.js": "~0.10.2"
 },

"devDependencies":{
"@angular-devkit/build-angular": "~0.901.15",
"@angular/cli": "~9.1.15",
"@angular/compiler-cli": "~9.1.13",
"@angular/language-service": "~9.1.13",
"@types/hammerjs": "^2.0.36",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^5.1.2",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-spec-reporter": "^0.0.32",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "3.8.3"
 }

Nothing what I've found in internet && stackoverflow did not bring any solution aparat from disabling Ivy which I want to avoid.

What else should I do to make this work?

Michał Sawicki
  • 49
  • 1
  • 10
  • 1
    Did you scroll up in the terminal log to check which errors are also thrown? This error means that one of the imported angular components, modules, ... or the module itself might have an error. – Mehyar Sawas Dec 13 '21 at 20:12
  • Yes indeed this error doesn't say anything more useful than "there is some error inside the subtree of that module". This can also happen if you place a Component as an import instead of the module providing that component by accident. – Malte Dec 13 '21 at 20:41
  • @MehyarSawas I have scrolled. No other errors apart from this mentioned. – Michał Sawicki Dec 14 '21 at 08:19
  • @Malte I guess that if such situation arises it would not compile in version 8 as well and in Angular 8 worked fine. – Michał Sawicki Dec 14 '21 at 08:21
  • Ok, then the best is to create a stackblitz example from your project to make it easier investigate and provide you a solution – Mehyar Sawas Dec 14 '21 at 17:14
  • What sometimes helps me. I just start removing each import from the module class and recompile and recheck until I figure it out which import causes the problem. – Mehyar Sawas Dec 14 '21 at 19:13
  • @MehyarSawas it's immposible to recreate this in stackblitz unfortunately and removing imports one by one also nothing changed. – Michał Sawicki Jan 13 '22 at 19:10

1 Answers1

0

Have you already made sure that your are not importing any of the components in the declarations array in another module?