angular: error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
π bug report
Preamble: Please do not mark as duplicate, as none of the workarounds in the other issues on NG6002 work here.
Affected Package
Building with Ivy enabled (sorry for being unprecise).
Is this a regression?
Not exactly a regression, just related to Ivy.
Description
I migrated a project from ~8 to 9.1.1, and it builds perfectly well - when "enableIvy": false
. With Ivy on, the below issue pops up. ngcc
is ran postinstall
. See public repo below to reproduce.
π¬ Reproduction
https://github.com/nikita-fuchs/fire-editor/tree/ivy9-repro
npm install
npm init
ng serve
π₯ Exception or Error
ERROR in node_modules/ng2-semantic-ui/dist/sui.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
This likely means that the library (ng2-semantic-ui) which declares SuiModule 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.
π Your Environment
Angular Version:
Angular CLI: 9.1.1
Node: 12.16.1
OS: darwin x64
Angular: 9.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.1
@angular-devkit/build-angular 0.901.1
@angular-devkit/build-optimizer 0.901.1
@angular-devkit/build-webpack 0.901.1
@angular-devkit/core 9.1.1
@angular-devkit/schematics 9.1.1
@angular/fire 5.2.3
@ngtools/webpack 9.1.1
@schematics/angular 9.1.1
@schematics/update 0.901.1
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
Anything else relevant?
As mentioned before, disabling Ivy in tsconfig.app.json
makes things build. The file deemed problematic by the builder looks pretty unproblematic to me :
export declare class SuiModule {
}
I really appreciate any help, thank you very much ! π
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (10 by maintainers)
holy cow @gkalpak , that was more help than I could have asked for, thank you so much. The library is not maintained since some time unfortunately, so I guess Iβll have to put a fork in place. I will give it a try as soon as I find out how to use the output of its
npm run lib:compile
cmd as a module in my project, copy pasting thedist
folder intonode_modules/ng2-semantic-ui/
didnβt do the trick.A breaking change warning would be nice, at least at runtime, when affected things are used, like
ContentChildren
- that would make debugging definitely easier.@petebacondarwin maybe that investigation would bring up useful insights for ngcc ?
As long as you are not doing server-side-rendering (i.e.
@angular/universal
, etc) then you can tell ngcc to βignoreβ themain
property, since for browser based apps the CLI will usemodule
beforemain
. You do this by adding angcc.config.js
file in the root of your project containing: