构建 angular 应用程序时出现错误“../node_modules/cdk-table-exporter/cdk-table-exporter。d.ts 没有选择器,请添加”

Error "../node_modules/cdk-table-exporter/cdk-table-exporter.d.ts has no selector, please add it"when building angular application

我安装了以下依赖项,仅用于在 angular 8:

中使用 mat-table-exporter
npm install mat-table-exporter --save 

现在,当我使用以下命令构建我的 angular 应用程序时:

ng build --prod --build-optimizer --aot --base-href=/application_base_name

我收到如下所示的错误:

PS C:\GitRepositories\cricket_aiops_dashboard\Client_Side>ng build --prod --build-optimizer --aot --base-href=/application_base_name
Your global Angular CLI version (9.1.0) is greater than your local
version (8.3.26). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

ERROR in Directive CdkTableExporter in C:/../Client_Side/node_modules/cdk-table-exporter/cdk-table-exporter.d.ts has no selector, please add it!

我尝试通过安装依赖项来解决它:npm install --save cdk-table-exporter 然后构建我的应用程序,但它仍然无法正常工作。

package.json

的内容如下
{
  "name": "ai-ops",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "8.2.3",
    "@angular/cli": "^8.3.26",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@ng-bootstrap/ng-bootstrap": "^5.3.0",
    "@syncfusion/ej2-angular-calendars": "^17.4.51",
    "@syncfusion/ej2-vue-calendars": "^17.4.51",
    "@types/jquery": "^3.3.31",
    "angular-google-charts": "^0.1.6",
    "angular2-datatable": "^0.6.0",
    "angular2-datatable-pagination": "0.0.3",
    "angular2-prettyjson": "^3.0.1",
    "bootstrap": "^4.4.1",
    "core-js": "^2.6.11",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.5.0",
    "mat-table-exporter": "^9.0.0",
    "ng-multiselect-dropdown": "^0.2.10",
    "ngx-json-viewer": "^2.4.0",
    "ngx-toastr": "^11.2.1",
    "popper.js": "^1.16.1",
    "rxjs": "^6.5.3",
    "rxjs-compat": "^6.5.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.26",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.3",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  }
}

请帮忙!

如果您使用的是低于 9 的 Angular 版本,您应该使用 mat-table-exporter@1.2.5。 使用这个 -> npm install --save mat-table-exporter@1.2.5

如果您已经安装了 mat-table-exporter,请将其卸载。 先卸载mat-table exporter,再卸载cdk-table-exporter。 然后使用上面的命令安装 mat-table-exporter@1.2.5。

来源 - https://github.com/HalitTalha/mat-table-extensions/issues/49

希望对你有所帮助,干杯!!

检查你的 angular 版本,如果低于 9 使用 mat-table-exporter@1.2.5

npm install --save mat-table-exporter@1.2.5