【问题标题】:Angular material. error while importing MatIconRegistry角材料。导入 MatIconRegistry 时出错
【发布时间】:2021-11-18 20:51:35
【问题描述】:

我正在使用“Angular: 10.0.14”和“@angular/material 10.2.7”,在尝试导入 MatIconRegistry 时出现此错误。

node_modules/@angular/material/icon/icon-registry.d.ts:51:22 中的错误 - 错误 NG6002:出现在 MaterialModule 的 NgModule.imports 中,但无法解析为 NgModule 类。

This likely means that the library (@angular/material/icon) which declares MatIconRegistry 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.

51 export declare class MatIconRegistry implements OnDestroy {
                        ~~~~~~~~~~~~~~~
node_modules/@angular/material/icon/icon-registry.d.ts:51:22 - error NG6003: Appears in the NgModule.exports of MaterialModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

This likely means that the library (@angular/material/icon) which declares MatIconRegistry 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.

51 export declare class MatIconRegistry implements OnDestroy {
                        ~~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6002: Appears in the NgModule.imports of FoodTypeModule, but itself has errors

54 export class MaterialModule { }
                ~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6002: Appears in the NgModule.imports of FoodItemModule, but itself has errors

540m export class MaterialModule { }
                ~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6002: Appears in the NgModule.imports of IngredientTypeModule, but itself has errors

54 export class MaterialModule { }
                ~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6002: Appears in the NgModule.imports of IngredientModule, but itself has errors

54 export class MaterialModule { }
                ~~~~~~~~~~~~~~
src/app/food-item/food-item.module.ts:24:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

24 export class FoodItemModule {}
                ~~~~~~~~~~~~~~
src/app/food-type/food-type.module.ts:25:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

25 export class FoodTypeModule {}
                ~~~~~~~~~~~~~~
src/app/ingredient/ingredient.module.ts:25:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

25 export class IngredientModule {}
                ~~~~~~~~~~~~~~~~
src/app/ingredient-type/ingredient-type.module.ts:25:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

25 export class IngredientTypeModule {}
                ~~~~~~~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6002: Appears in the NgModule.imports of AppModule, but itself has errors

54 export class MaterialModule { }
                ~~~~~~~~~~~~~~
src/app/material/material.module.ts:54:14 - error NG6003: Appears in the NgModule.exports of AppModule, but itself has errors

54 export class MaterialModule { } 

【问题讨论】:

    标签: angular angular-material mat-icon


    【解决方案1】:

    通过从我的材质模块中删除 MatIconRegistry 的导入并将其导入我想要使用它的组件中,问题已得到解决。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多