angular: Appears in the NgModule.imports of , but could not be resolved to an NgModule class

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler 9.0.0-rc.11

Is this a regression?

Yes. In v8.2.14 it worked properly.

Description

at my app, I using library built by me with angular v8.0.3 and @angular/material v.8.1.2 and ng-packagr. then, error occured after update app to angular v9.0.0-rc.11.

ERROR in Failed to compile entry-point my-library (es2015 as esm2015) due to compilation errors:
vendor/my-library/dist/mylibrary-shared-feedback-dialog/node_modules/@angular/material/dialog/typings/dialog-module.d.ts:8:22 - error NG6002: Appears in the NgModule.imports of MyLibrarySharedFeedbackDialogModule, but could not be resolved to an NgModule class

8 export declare class MatDialogModule {

A similar error occurs for the imported Angular Material Module.

🌍 Your Environment

Angular Version:




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.0.0-rc.10
Node: 12.14.0
OS: linux x64

Angular: 9.0.0-rc.11
... 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.0-rc.10
@angular-devkit/build-angular      0.900.0-rc.10
@angular-devkit/build-optimizer    0.900.0-rc.10
@angular-devkit/build-webpack      0.900.0-rc.10
@angular-devkit/core               9.0.0-rc.10
@angular-devkit/schematics         9.0.0-rc.10
@angular/cdk                       9.0.0-rc.8
@angular/cli                       9.0.0-rc.10
@angular/flex-layout               8.0.0-beta.27
@angular/material                  9.0.0-rc.8
@angular/material-moment-adapter   9.0.0-rc.8
@ngtools/webpack                   9.0.0-rc.10
@schematics/angular                9.0.0-rc.10
@schematics/update                 0.900.0-rc.10
rxjs                               6.5.3
typescript                         3.7.5
webpack                            4.41.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Hi,

Created a new Angular 9 project and added angular material 9 from: using the command ng add @angular/material

I then followed the steps mentioned in the link to display a simple checkbox using Angular Material. The checkbox is displayed fine. However, the cli complains with the below error:

image

I then deleted the node_modules and did a npm install again. It seems to have fixed the issue.

Could you please try the following:

  1. Delete node_modules
  2. npm install

Repo: https://github.com/VedantKarpe/angular9

Guys, i have some solution but im not sure how currect it is.

1. "buildOptimizer": false,
2. "enableIvy": true
3. "aot": false,

Before do this refactoring, application size is: 18 440KB; After: 17 887KB

Just a note: If you do not provide a (minimal) reproduction, there pretty much nothing we can do to investigate, fix or verify a potential fix for your usecase πŸ€·β€β™‚

having same issue. we have following scenario.

shared libraries built and published using rc11. seperate app that consumes those libraries also in rc11.

i have a private repo with ability to recreate this issue. let me know if anyone wants to have access to troubleshoot the issue.

i was able to resolve this issue on our npm libraries. added β€œimportHelpers”: true to the tsconfig for lib builds. then remove the β€œprocessed_by_ivy_ngcc” section from package.json under build library artifacts before npm publish.

same issue occurs in rc12. I have a library with disabling Ivy and consume that library in another angular project where enabling Ivy throws the below error.

ERROR in node_modules/@ex/ui/input/uiinput.module.d.ts:7:22 - error NG6002: Appears in the NgModule.imports of <ownmodule>, but could not be resolved to an NgModule class

in package referring the library - β€œ@ex/ui”: β€œfile:…/<libfolder>/dist/ui”, But this issue not occurs when we publish the library to npm and access it - β€œ@ex/ui”: β€œ^1.0.0”