question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nikita-fuchscommented, Apr 17, 2020

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 the dist folder into node_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 ?

1reaction
petebacondarwincommented, Apr 10, 2020

As long as you are not doing server-side-rendering (i.e. @angular/universal, etc) then you can tell ngcc to “ignore” the main property, since for browser based apps the CLI will use module before main. You do this by adding a ngcc.config.js file in the root of your project containing:

module.exports = {
  packages: {
    'ng2-semantic-ui': {
      entryPoints: {
        '.': {
          override: {
            main: undefined
          }
        }
      }
    }
  }
};
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found