ng Zorro - StaticInjectorError(AppModule)[覆盖]

ngZorro - StaticInjectorError(AppModule)[Overlay]

我在我的项目中使用 ng-zorro,在 --prod 之后出现以下错误。 通常做服务器不会产生这个错误。 我发现了这个 git post https://github.com/NG-ZORRO/ng-zorro-antd/issues/3713#issuecomment-513933229 但对我来说没用。

main-es2015.fa929b87a49d088ae223.js:36985 ERROR NullInjectorError: StaticInjectorError(AppModule)[Overlay]: 
  StaticInjectorError(Platform: core)[Overlay]: 
    NullInjectorError: No provider for Overlay!

我的package.json文件

{
  "name": "sporttzzmeetup",
  "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": "~8.2.10",
    "@angular/cdk": "~8.2.1",
    "@angular/common": "~8.2.10",
    "@angular/compiler": "~8.2.10",
    "@angular/core": "~8.2.10",
    "@angular/forms": "~8.2.10",
    "@angular/platform-browser": "~8.2.10",
    "@angular/platform-browser-dynamic": "~8.2.10",
    "@angular/router": "~8.2.10",
    "core-js": "^2.5.4",
    "ng-zorro-antd": "^8.3.1",
    "rxjs": "~6.5.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.8",
    "@angular/cli": "~8.3.8",
    "@angular/compiler-cli": "~8.2.10",
    "@angular/language-service": "~8.2.10",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@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.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  }
}


进口 app.module.ts 该项目与 ng 服务器一起正常工作。

@NgModule({
  declarations: [
    AppComponent,
    CommentsComponent,
  ],
  imports: [
    FlexLayoutModule,
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    ReactiveFormsModule,
    HttpClientModule,
    BrowserAnimationsModule,
    NgZorroAntdModule
  ],
  providers: [
    GlobalService,
    RouteGuardService,
    { provide: HTTP_INTERCEPTORS, useClass: HttpAuthInterceptor, multi: true },
    { provide: NZ_I18N, useValue: en_US }],
  bootstrap: [AppComponent]
})
export class AppModule { }

为了达到预期的结果,请检查您的 ng-zorro 和 angular 版本以避免因版本不匹配而导致上述错误