angular: Error NG6002: Upgraded LIB to NG9

šŸž bug report

Affected Package

There is a similar problem https://github.com/angular/angular/issues/35536 and if I follow instructions from this issue it works as a workaround

Is this a regression?

Yes. NG8 has no problem compiling local libs and local app to test it.

Description

As you can see it here at MetaUI, I have libs and apps folders.

Libs contains two libraries ( that we shoudl care about now):

  • rules - core rules engine library
  • material-rules - Specific UI library implementation for rules. It also uses and imports core rules library

Then I have apps as playground:

  • material-app: which imports both libraries.

The normal workflow in NG8 to be able to test material-app was:

ng build rules 
ng build material-rules
ng build material-app
ng serve material-app

Now ng build material-app fails with NG6002 & NG6003 errors.

But if I follow #35536, and run npx ngcc && ngcc -s dist before building material-app, all works. so Running:

rm -Rf dist && ng build rules && ng build material-rules && npx ngcc && ngcc -s dist
ng build material-app

fixes problem

šŸ”¬ Minimal Reproduction

git clone -b ng9 https://github.com/ngx-meta/rules.git
cd rules/
npm install

// Now you can run to see errors
rm -Rf dist && ng build rules && ng build material-rules && ng build material-app

// run to fix it
rm -Rf dist && ng build rules && ng build material-rules && npx ngcc && ngcc -s dist
ng build material-app

šŸ”„ Exception or Error



ERROR in dist/libs/rules/lib/metaui/rules.module.d.ts:27:22 - error NG6002: Appears in the NgModule.imports of MetaUILibLayoutModule, but could not be resolved to an NgModule class.

This likely means that the dependency (@ngx-metaui/rules) which declares MetaUIRulesModule has not been processed correctly by ngcc.

27 export declare class MetaUIRulesModule {
                        ~~~~~~~~~~~~~~~~~
libs/material-rules/src/lib/metaui/meta-ui-layout.module.ts:71:14 - error NG6002: Appears in the NgModule.imports of MaterialRulesModule, but itself has errors

71 export class MetaUILibLayoutModule {
                ~~~~~~~~~~~~~~~~~~~~~
dist/libs/rules/lib/metaui/rules.module.d.ts:27:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the dependency (@ngx-metaui/rules) which declares MetaUIRulesModule has not been processed correctly by ngcc.

27 export declare class MetaUIRulesModule {
                        ~~~~~~~~~~~~~~~~~
libs/material-rules/src/lib/material-rules.module.ts:40:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

40 export class MaterialRulesModule {

šŸŒ Your Environment

Angular Version:


Angular CLI: 9.0.6
Node: 12.0.0
OS: darwin x64

Angular: 9.0.7
... 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.6
@angular-devkit/build-angular      0.900.6
@angular-devkit/build-ng-packagr   0.900.6
@angular-devkit/build-optimizer    0.900.6
@angular-devkit/build-webpack      0.900.6
@angular-devkit/core               9.0.7
@angular-devkit/schematics         9.0.7
@angular/cdk                       9.1.2
@angular/cli                       9.0.6
@angular/material                  9.1.2
@ngtools/webpack                   9.0.6
@schematics/angular                9.0.6
@schematics/update                 0.900.6
ng-packagr                         9.0.3
rxjs                               6.5.4
typescript                         3.7.5
webpack                            4.41.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I can confirm that locally #36305 also fixes your problem @boskiv .

So guys, Iā€™m not quite sure what I have to do to get it working in my case? šŸ˜ƒ https://github.com/NG-ZORRO/ng-zorro-antd/issues/4917 Can you advise?

šŸ‘ Glad that got you moving. Please raise new issues if you have further problems.