【问题标题】:Using FlexLayoutModule gives error in Angular 11在 Angular 11 中使用 FlexLayoutModule 会出错
【发布时间】:2021-08-25 03:36:58
【问题描述】:

我已经安装了FlexLayoutModule,并在遇到此错误时声明了它:

Error: node_modules/@angular/flex-layout/typings/module.d.ts:16: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 (@angular/flex-layout/typings/module) which declares FlexLayoutModule 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.

16 export declare class FlexLayoutModule {
                        ~~~~~~~~~~~~~~~~

可能出了什么问题?
FlexLayoutModule的版本是11.0.0-beta.33

【问题讨论】:

    标签: angular angular11


    【解决方案1】:

    我遇到了同样的问题。我通过导入不是 FlexLayoutModule 而是 FlexModule 来修复它:

    import { FlexModule } from '@angular/flex-layout';
    

    那是我的 package.json:

    "dependencies": {
    "@angular/animations": "~11.0.5",
    "@angular/cdk": "^11.0.3",
    "@angular/common": "~11.0.5",
    "@angular/compiler": "~11.0.5",
    "@angular/core": "~11.0.5",
    "@angular/flex-layout": "^11.0.0-beta.33",
    "@angular/forms": "~11.0.5",
    "@angular/material": "^11.0.3",
    "@angular/platform-browser": "~11.0.5",
    "@angular/platform-browser-dynamic": "~11.0.5",
    "@angular/router": "~11.0.5",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
    },
    

    【讨论】:

      【解决方案2】:

      这可能是 IDE 自动完成问题。

      导入FlexLayoutModule 时,请确保它是从@angular/flex-layout 导入的。 esm5 包中还有一个 FlexLayoutModule,它与 Angular 9 或更高版本不兼容。

      import { FlexLayoutModule } from "@angular/flex-layout";
      
      . . .
      
      imports: [
          . . .
          FlexLayoutModule
        ],
      . . . 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-16
        • 2021-02-24
        • 1970-01-01
        • 2021-05-02
        • 1970-01-01
        • 2021-04-21
        相关资源
        最近更新 更多