While updating my Angular Material Starter Template to Angular 14, I ran into an error causing broken builds. The console output seems to suggest this is a problem with Dialog
module from Angular Component Dev Kit (CDK): Cannot resolve type entity i3.DialogModule to symbol.
./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i3.DialogModule to symbol
Error: node_modules/@angular/material/dialog/index.d.ts:3:36 - error TS2307: Cannot find module '@angular/cdk/dialog' or its corresponding type declarations.
3 import { CdkDialogContainer } from '@angular/cdk/dialog';
Code language: JavaScript (javascript)
After hours of research online with no luck, it turns out I never had @angular/cdk
as a dependency in the project.
I found this out by checking the getting started section of Angular Material docs.
How to fix Error: Cannot resolve type entity i3.DialogModule to symbol:
- Open up
package.json
file - Add
@angular/cdk
to dependencies section: - Run
npm install
to update download the new package
It doesn’t matter where you put the new dependency, as long as it is within the dependencies block.
One thing to watch out for is using the correct version – it must match the rest of the Angular packages.
In the code snippet below, you can see I am using version ^14.2.1
because all other angular packages are on this version.
....
"dependencies": {
"@angular/animations": "^14.2.1",
"@angular/common": "^14.2.1",
"@angular/compiler": "^14.2.1",
"@angular/core": "^14.2.1",
"@angular/cdk": "^14.2.1",
...
}
...
Code language: JavaScript (javascript)
I hope this post helped you solve this problem!
It is really not clear to my why I didn’t have this error in Angular 13. After all, a missing dependency should break builds, right? Let me know in the comments, if you know why.
Dude thanks for this post it really helped!!