ngZorro in Lazy-loaded module error: [NzModalComponent -> Overlay] No provider for Overlay!
See original GitHub issueReproduction link
Steps to reproduce
Import/export NgZorroAntdModule from a Lazy-loaded module. You will get the error:
Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[NzModalComponent -> Overlay]:
StaticInjectorError(Platform: core)[NzModalComponent -> Overlay]:
NullInjectorError: No provider for Overlay!
Error: NullInjectorError: No provider for Overlay!
What is expected?
No error
What is actually happening?
Best guess: Lazy-loaded NgZorroAntdModule does not have access to dependency CDK Overlay.
Adding this to the main app.module fixes it:
import { OverlayModule } from '@angular/cdk/overlay';
....
import: [
...
OverlayModule
| Environment | Info |
|---|---|
| ng-zorro-antd | 8.0.1 |
| Browser | Chrome Version 75.0.3770.100 (Official Build) (64-bit) |
This is very similar to the case: https://stackoverflow.com/questions/56268515/ng-zorro-datepicker-components-error-in-lazy-loaded-feature-modules/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Error: No provider for Overlay! - angular - Stack Overflow
I managed to eliminate this error by adding this to app.module.js: import {OVERLAY_PROVIDERS} from "@angular/material"; @NgModule({ imports: ...
Read more >ng-zorro/ng-zorro-antd - Gitter
Hello, Im getting this 'No provider for Overlay!' error while creating production build. I have listed the error and files used in app.module...
Read more >Modal | NG-ZORRO
In the popup layer component, you can obtain Modal's component instance by injecting ... when the loading is over, the modal dialog will...
Read more >ng-zorro-antd | Yarn - Package Manager
ng -zorro-antd ... An enterprise-class UI components based on Ant Design and Angular ... drawer: fix nzContentParams definition error (#7668 (0074013), ...
Read more >How to build a reusable Modal Overlay/Dialog Using Angular ...
Let us get the basics out of the way first. Assuming you have installed Angular CDK you will need to import OverlayModule into...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My problem was that I had two cdk directories in node_modules. One in node_modules itself and one in the node_modules directory inside ng-zorro-antd directory. This was my yarn.lock:
and I replaced that by:
you can try rm -rf node_modules and reinstall your dependency