question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StaticInjectorError(AppModule)[CdkConnectedOverlay -> Overlay]

See original GitHub issue

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-hspl9z?file=package.json

Steps to reproduce

Build works perfectly when doing a normal ng serve. Doing a --prod build compiles correctly. However browsing to the site in a browser that has been built in --prod mode, does not work.

I see that ng-zorro has a dependency on @angular/cdk. I also need to use the cdk dep in my own project so I need to add a reference to the project. As 7.5.1 uses cdk 7.3.7 as a dependency (from lock file), I added this version to my project.

I do not know what could be causing this.

What is expected?

Running an angular site in --prod mode should work correctly. Currently I have a site that does not work properly now.

What is actually happening?

In the browser, there are many errors like this:

ERROR Error: StaticInjectorError[t -> t]: 
  StaticInjectorError(Platform: core)[t -> t]: 
    NullInjectorError: No provider for t!

If you disable the terser step of a --prod build the error looks as follows:

main.69af81de163627084b5e.js:28873 ERROR Error: StaticInjectorError(AppModule)[CdkConnectedOverlay -> Overlay]:
 StaticInjectorError(Platform: core)[CdkConnectedOverlay -> Overlay]:
   NullInjectorError: No provider for Overlay!
Environment Info
ng-zorro-antd 7.5.1
Browser Chrome

Note I cannot update to angular 8 and the latest version of ng-zorro just yet.

My packages file:

"dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/cdk": "7.3.7",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@auth0/angular-jwt": "^2.1.0",
    "@swimlane/ngx-charts": "^12.0.1",
    "angular-datatables": "^8.0.0",
    "angularx-qrcode": "^1.6.0",
    "bootstrap": "^4.3.1",
    "chart.js": "^2.8.0",
    "color-hash": "^1.0.3",
    "core-js": "^2.5.4",
    "datatable-sorting-datetime-moment": "^1.0.1",
    "datatables.net": "^1.10.19",
    "datatables.net-bs4": "^1.10.19",
    "datatables.net-buttons": "^1.5.6",
    "datatables.net-buttons-bs4": "^1.5.6",
    "datatables.net-responsive": "^2.2.3",
    "datatables.net-responsive-bs4": "^2.2.3",
    "file-saver": "^2.0.2",
    "jquery": "^3.4.1",
    "moment": "^2.24.0",
    "ng-zorro-antd": "^7.5.1",
    "ng2-charts": "2.2.5",
    "ngx-color-picker": "^8.0.1",
    "ngx-page-scroll-core": "^6.0.2",
    "ngx-summernote": "^0.6.5",
    "rxjs": "~6.3.3",
    "summernote": "^0.8.12",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.9",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/datatables.net": "^1.10.17",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jquery": "^3.3.29",
    "@types/node": "^8.9.5",
    "codelyzer": "~4.5.0",
    "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.2.2",
    "webpack-bundle-analyzer": "3.3.2"
  }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
thinkdjcommented, Jul 7, 2020

For anyone who’s still stuck with these: I spent ~6 hours behind this. Got it working via some hacky methods (removing/replacing zorro’s dependency version, matching my project’s CDK with zorro’s … ) Finally, upgrading angular + cdk + zorro to the latest (8.x/9.x) seemed to be the best solution. The time invested in this migration was very well worth it on multiple levels. Zero hacks, zero errors now.

1reaction
thinkdjcommented, Jul 7, 2020

@amiram is right! I had the same problem. I have angularCDK in package.json and ngZorro is having another version as a dependency and this causes issues always

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular StaticInjectorError(AppModule)[CdkConnectedOverlay
I put OverlayModule in app.module.ts, but this is not work. full package.json : "dependencies": { "@angular/animations": ...
Read more >
Uncaught (in promise): NullInjectorError: StaticInjectorError ...
Coding example for the question Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[CdkConnectedOverlay -> Overlay]-angular.js.
Read more >
angular/material2 - Gitter
Hey All, I recently updated from ang 5 to 6, and when running AOT builds I get StaticInjectorError(AppModule)[CdkConnectedOverlay -> Overlay]: .
Read more >
No provider for Overlay!” in console (Angular Material ...
Specifically, ERROR Error: Uncaught (in promise): Error: StaticInjectorError(AppModule)[CdkConnectedOverlay -> Overlay]: StaticInjectorError(Platform: core)[ ...
Read more >
Overlay | Angular Material
import {OverlayModule} from '@angular/cdk/overlay'; ... Selector: [cdk-connected-overlay] [connected-overlay] [cdkConnectedOverlay].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found