error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
See original GitHub issue🐞 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 ! 🏆
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Appears in the NgModule.imports of AppModule, but could not ...
error NG6002 : Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class · 10. restarting console helped...
Read more >Answer: error NG6002: Appears in the NgModule.imports of ...
answer re: error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class ... Fixed it by...
Read more >IVY Error NG6002: Appears in the NgModule.imports ... - GitHub
IVY Error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class #35399.
Read more >error NG6002 - Angular - CodeDocu.com
Angular Error: error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Read more >'formsmodule' does not appear to be an ngmodule class.
angular/angularIVY Error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class#35399.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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: