错误的含义是什么以及如何修复它
错误消息是:
Error: src/app/app.component.html:29:4 - error NG8001: 'router-outlet' is not a known element:
1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
29 <router-outlet></router-outlet>
~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
Error: src/app/app.component.html:31:4 - error NG8001: 'progress-bar' is not a known element:
1. If 'progress-bar' is an Angular component, then verify that it is part of this module.
2. If 'progress-bar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
31 <progress-bar *ngIf="showLoader"></progress-bar>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/app.component.ts:7:16
7 templateUrl: './app.component.html',
~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component AppComponent.
Error: src/app/app.module.ts:26:5 - error NG6001: Cannot declare 'TableModule' in an NgModule as it's not a part of the current compilation.
26 TableModule,
~~~~~~~~~~~
node_modules/primeng/table/table.d.ts:1397:22
1397 export declare class TableModule {
~~~~~~~~~~~
'TableModule' is declared here.
app.module.ts - 我在这里尝试过
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ProgressBarComponent } from './_helpers/progress-bar/progress-bar.component';
import { CitationDashboardComponent } from './modules/citation-dashboard/citation-dashboard.component';
import { TableFilterPipe } from './pipes/tabular-filter.pipe';
import { GenericHttpService } from 'src/app/config/GenericHttp/generic-http.service'
import { NgSelectModule } from "@ng-select/ng-select";
import { HttpClientModule } from '@angular/common/http';
import { TableModule } from 'primeng/table';
import { httpInterceptProviders } from './http-interceptors/auth-index';
import { HomePageComponent } from './modules/home-page/home-page.component';
// import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
// import { NO_ERRORS_SCHEMA,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
declarations: [
AppComponent,
ProgressBarComponent,
TableFilterPipe,
TableModule,
CitationDashboardComponent,
HomePageComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
NgSelectModule,
HttpClientModule,
AppRoutingModule
],
// schemas: [
// CUSTOM_ELEMENTS_SCHEMA,
// NO_ERRORS_SCHEMA
// ],
providers: [GenericHttpService, httpInterceptProviders],
bootstrap: [AppComponent]
})
export class AppModule { }
安装primeng后我开始面临这个问题。现在我卸载了primeng,但问题仍然存在。附加 package.json 以获取软件包版本详细信息
{
"name": "ermapplications",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@ng-bootstrap/ng-bootstrap": "^15.0.0",
"@ng-select/ng-option-highlight": "^11.1.1",
"@ng-select/ng-select": "^11.0.0",
"@types/file-saver": "^2.0.7",
"bootstrap": "^5.2.0",
"fontawesome": "^5.6.3",
"hammerjs": "^2.0.8",
"jquery": "^3.6.1",
"polyfills": "^2.1.1",
"popper.js": "^1.16.1",
"primeicons": "^7.0.0",
"primeng": "^16.9.1",
"tslib": "^2.3.0",
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.0",
"@angular/cli": "~16.0.0",
"@angular/compiler-cli": "^16.0.0",
"@types/jasmine": "~4.3.0",
"@types/jquery": "^3.5.14",
"@types/node": "^12.11.1",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"rxjs": "^6.5.3",
"typescript": "^4.9.3",
"webpack-dev-server": "^4.15.1"
},
"description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.0.0.",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC"
}
模块 (
TableModule
) 属于导入数组,也许这会导致出现错误列表!
@NgModule({
declarations: [
AppComponent,
ProgressBarComponent,
TableFilterPipe,
// TableModule, // <- remove this.
CitationDashboardComponent,
HomePageComponent
],
imports: [
TableModule, // <- add here
BrowserModule,
FormsModule,
ReactiveFormsModule,
CommonModule,
NgSelectModule,
HttpClientModule,
AppRoutingModule
],
// schemas: [
// CUSTOM_ELEMENTS_SCHEMA,
// NO_ERRORS_SCHEMA
// ],
providers: [GenericHttpService, httpInterceptProviders],
bootstrap: [AppComponent]
})
export class AppModule { }