Skip to content

IVY Error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class #35399

@stevethemacguy

Description

@stevethemacguy

🐞 bug report

Affected Package

The issue might be related to package

ng-packagr

Is this a regression?

Yes, the previous version in which this bug was not present was: 8.2.14

Description

Possible duplicate of #35331, #34983, #35255, and #30972, but I'm including a minimal reproduction repo. Building with IVY throws the following error (see the Exception or Error section)

StackBlitz Error

Our real app, which uses a shared module, throws a slightly different error:

Concise Error

Running the ng-packagr postinstall script adds "ivy_ngcc" folders to some of our other dependencies, but does not touch the angular2-highcharts library. The library does not use the Angular Package Format, which might be part of the problem, but I'm not the library's author and have never built an ES6/angular library myself, so I'm just guessing at a potential fix.

Unfortunately, the library is no longer maintained, but it is one of our app's core/major dependencies. I also attempted to rebuild the library from the source files after adding the following to the library's package.json file:


"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
"ngPackage": {
  "lib": {
    "entryFile": "index.d.ts"
  }
},

But this produces the following error:

Error

There is no "files" array provided in the library's package.json file, so I'm not sure what the error is referring to. I fixed all Angular 9-related issues prior to re-building the library, so I assume it has to do with the way it's packaged or how it exports the modules/components.

🔬 Minimal Reproduction

StackBlitz
https://angular-ivy-cant-be-resolved.stackblitz.io

GitHub repo in case StackBlitz isn't working:
https://github.com/stevethemacguy/angular-ivy-cant-be-resolved-bug

Steps to Reproduce

  1. Download or clone the repo
  2. npm install
  3. ng build (or ng serve)

Expected behavior: IVY builds the app
Actual behavior: IVY displays an error.

🔥 Exception or Error

ERROR in node_modules/angular2-highcharts/dist/index.d.ts:8:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

8 export declare class ChartModule {

🌍 Your Environment

Angular Version:

Angular CLI: 9.0.2
Node: 10.15.3
OS: darwin x64

Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.2
@angular-devkit/build-angular     0.900.2
@angular-devkit/build-optimizer   0.900.2
@angular-devkit/build-webpack     0.900.2
@angular-devkit/core              9.0.2
@angular-devkit/schematics        9.0.2
@angular/cli                      9.0.2
@ngtools/webpack                  9.0.2
@schematics/angular               9.0.2
@schematics/update                0.900.2
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?
After disabling IVY, our real app successfully builds in AOT (prod mode) using Angular 9.0.1, so the issue seems to be an Angular regression that is un-related to our app (except for the angular2-highcharts dependency). Our app uses a custom angular/webpack build. It does not use Angular CLI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compiler

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions