Angular 角度9或10+;角度材质10:无法将导入解析为NgModule类
我用Angular 9和最新版本的材料做了一个新项目。导入某些材质的类时,出现以下错误: 节点_modules/@angular/material/form field/label.d.ts:10:22中出错-错误NG6002:出现在物料模块的NgModule.imports中,但无法解析为NgModule类 这可能意味着声明MatLabel的库(@angular/material/form字段)未被ngcc正确处理,或者与angular Ivy不兼容。检查库的更新版本是否可用,如果可用,请进行更新。同时考虑与图书馆的作者一起检查图书馆是否与常春藤兼容。 10出口申报类别标签{ ~~~~~~~~ 节点_modules/@angular/material/form field/hint.d.ts:20:22-错误NG6002:出现在材料模块的NgModule.imports中,但无法解析为NgModule类 这可能意味着库(@angular/material/form字段)声明MaTiTt没有被NGCC正确处理,或者与角常春藤不兼容。检查是否有一个新版本的库可用,如果有更新,也可以考虑与库的作者一起检查,看看库是否与常春藤兼容。 20导出声明类MatHint{ ~~~~~~~ src/app/material.module.ts:12:14-错误NG6002:出现在AppModule的NgModule.imports中,但无法解析为NgModule类 是否缺少@NgModule注释 12导出类MaterialModule{} ~~~~~~~~~~~~~~ 节点_modules/@angular/material/form field/label.d.ts:10:22中出错-错误NG6002:出现在物料模块的NgModule.imports中,但无法解析为NgModule类 这可能意味着库(@angular/material/form字段)它声明MatLabor没有被NGCC正确处理,或者与角常春藤不兼容。检查是否有新版本的库可用,如果有更新,也可以考虑与库的作者一起检查,看看库是否与常春藤兼容。< /P> 10出口申报类别标签{ ~~~~~~~~ 节点_modules/@angular/material/form field/hint.d.ts:20:22-错误NG6002:出现在材料模块的NgModule.imports中,但无法解析为NgModule类 这可能意味着库(@angular/material/form字段)声明MaTiTt没有被NGCC正确处理,或者与角常春藤不兼容。检查是否有一个新版本的库可用,如果有更新,也可以考虑与库的作者一起检查,看看库是否与常春藤兼容。 20导出声明类MatHint{ ~~~~~~~ src/app/material.module.ts:12:14-错误NG6002:出现在AppModule的NgModule.imports中,但无法解析为NgModule类 是否缺少@NgModule注释 12导出类MaterialModule{} ~~~~~~~~~~~~~~ 材料.模块.tsAngular 角度9或10+;角度材质10:无法将导入解析为NgModule类,angular,angular-material,angular-ivy,Angular,Angular Material,Angular Ivy,我用Angular 9和最新版本的材料做了一个新项目。导入某些材质的类时,出现以下错误: 节点_modules/@angular/material/form field/label.d.ts:10:22中出错-错误NG6002:出现在物料模块的NgModule.imports中,但无法解析为NgModule类 这可能意味着声明MatLabel的库(@angular/material/form字段)未被ngcc正确处理,或者与angular Ivy不兼容。检查库的更新版本是否可用,如果可用,请进行
import { NgModule } from '@angular/core';
import {
MatFormFieldModule,
MatLabel,
MatHint,
} from '@angular/material/form-field';
@NgModule({
imports: [MatFormFieldModule, MatLabel, MatHint],
exports: [MatFormFieldModule, MatLabel, MatHint],
})
export class MaterialModule {}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { MaterialModule } from './material.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CarouselComponent } from './carousel/carousel.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { CrudComponent } from './crud/crud.component';
import { ProfileComponent } from './profile/profile.component';
import { LayoutComponent } from './layout/layout.component';
import { FooterComponent } from './layout/footer/footer.component';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { LoginComponent } from './login/login.component';
import { PrivHeaderComponent } from './layout/priv-header/priv-header.component';
import { PrivMenuComponent } from './layout/priv-menu/priv-menu.component';
import { MainMenuComponent } from './layout/main-menu/main-menu.component';
import { MainHeaderComponent } from './layout/main-header/main-header.component';
@NgModule({
declarations: [
AppComponent,
CarouselComponent,
DashboardComponent,
CrudComponent,
ProfileComponent,
LayoutComponent,
FooterComponent,
HomeComponent,
AboutComponent,
LoginComponent,
PrivHeaderComponent,
PrivMenuComponent,
MainMenuComponent,
MainHeaderComponent,
],
imports: [
BrowserModule,
FormsModule,
MaterialModule,
ReactiveFormsModule,
AppRoutingModule,
BrowserAnimationsModule,
],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
应用程序模块.ts
import { NgModule } from '@angular/core';
import {
MatFormFieldModule,
MatLabel,
MatHint,
} from '@angular/material/form-field';
@NgModule({
imports: [MatFormFieldModule, MatLabel, MatHint],
exports: [MatFormFieldModule, MatLabel, MatHint],
})
export class MaterialModule {}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { MaterialModule } from './material.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CarouselComponent } from './carousel/carousel.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { CrudComponent } from './crud/crud.component';
import { ProfileComponent } from './profile/profile.component';
import { LayoutComponent } from './layout/layout.component';
import { FooterComponent } from './layout/footer/footer.component';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { LoginComponent } from './login/login.component';
import { PrivHeaderComponent } from './layout/priv-header/priv-header.component';
import { PrivMenuComponent } from './layout/priv-menu/priv-menu.component';
import { MainMenuComponent } from './layout/main-menu/main-menu.component';
import { MainHeaderComponent } from './layout/main-header/main-header.component';
@NgModule({
declarations: [
AppComponent,
CarouselComponent,
DashboardComponent,
CrudComponent,
ProfileComponent,
LayoutComponent,
FooterComponent,
HomeComponent,
AboutComponent,
LoginComponent,
PrivHeaderComponent,
PrivMenuComponent,
MainMenuComponent,
MainHeaderComponent,
],
imports: [
BrowserModule,
FormsModule,
MaterialModule,
ReactiveFormsModule,
AppRoutingModule,
BrowserAnimationsModule,
],
providers: [],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppModule {}
package.json
{
"name": "mini-aplicacion",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~10.0.5",
"@angular/cdk": "^10.1.0",
"@angular/common": "~10.0.5",
"@angular/compiler": "~10.0.5",
"@angular/core": "~10.0.5",
"@angular/forms": "~10.0.5",
"@angular/material": "^10.1.0",
"@angular/platform-browser": "~10.0.5",
"@angular/platform-browser-dynamic": "~10.0.5",
"@angular/router": "~10.0.5",
"rxjs": "~6.5.4",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.4",
"@angular/cli": "~10.0.4",
"@angular/compiler-cli": "~10.0.5",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~3.3.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.9.7"
}
}
我试图删除节点_模块并重新安装。此外,我将Angular版本更新为10,Material版本,但问题仍然存在
我查看了其他类似的问题,但没有解决方案可以解决我的问题。MatLabel和MatHint包含在MatFormFieldModule中,您不必导入它们。只导入MatFormFieldModule,如前所述