我试图编译我的项目,但出现错误:
Error: Error on worker #3: Error: No typings declaration can be found for the referenced NgModule class in static withConfig(configOptions,
// tslint:disable-next-line:max-line-length
breakpoints = []) {
return {
ngModule: FlexLayoutModule,
providers: configOptions.serverLoaded ?
[
{ provide: LAYOUT_CONFIG, useValue: Object.assign(Object.assign({}, DEFAULT_CONFIG), configOptions) },
{ provide: BREAKPOINT, useValue: breakpoints, multi: true },
{ provide: SERVER_TOKEN, useValue: true },
] : [
{ provide: LAYOUT_CONFIG, useValue: Object.assign(Object.assign({}, DEFAULT_CONFIG), configOptions) },
{ provide: BREAKPOINT, useValue: breakpoints, multi: true },
]
};
}.
我用过
ng add @angular/material
和npm install @angular/flex-layout@latest --save
,我得到了这个错误。
直到现在我都尝试过:
我的依赖项看起来像:
"dependencies": {
"@angular/animations": "^9.1.11",
"@angular/cdk": "^9.2.4",
"@angular/common": "~9.1.11",
"@angular/compiler": "~9.1.11",
"@angular/core": "~9.1.11",
"@angular/flex-layout": "^10.0.0-beta.32",
"@angular/forms": "~9.1.11",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.11",
"@angular/platform-browser-dynamic": "~9.1.11",
"@angular/router": "~9.1.11",
"rxjs": "~6.5.5",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
}
有人知道这可能是错误的吗?
我的app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
SharedModule,
HomeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
但是我将Flex添加到了共享模块中,所以我还将粘贴了shared.module.ts
@NgModule({
declarations: [],
imports: [
CommonModule,
FlexLayoutModule
],
exports: [
FlexLayoutModule
]
})
export class SharedModule { }
答案 0 :(得分:42)
切换回FlexLayout 9.0.0-beta.31
。根据其更改日志,您正在使用的版本“(...)添加了对Angular v10和Angular CDK v10的支持。”
@angular的ModuleWithProviders
在@angular 9.x.x中不是泛型。但它在@angular 10 rc.x中。 FlexLayout x.x.x-beta.32
开始使用通用版本(ModuleWithProviders<T>
),因此它不适用于<角度版本<10的@angular。您需要切换回FlexLayout 9.0.0-beta.31
。
在package.json中,将"@angular/flex-layout": "^10.0.0-beta.32"
的{{1}}替换为"@angular/flex-layout": "~9.0.0-beta.31"
,然后再次运行npm install
(或简单地npm install @angular/flex-layout@9.0.0-beta.31"
)
答案 1 :(得分:12)
通过命令重新安装弹性布局
npm i @angular/flex-layout@9.0.0-beta.31