This error occurs when there is a mismatch in your angular version and material version.
To see the error go to package.json file where you can find the angular version and the material version.
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/cdk": "^6.2.1", //ERROR here the version is 6.x
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^6.2.1", // ERROR here the material version is 6.x
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"}
},
As you can see in the above package.json file there is mismatch of the version.
There are two ways to solve this error:
- Upgrade your angular by using command: ng update (this will change your angular versio to 6.x).
- Change the version of cdk and material to 5.2.0 manually then enter the command: npm install this will add the material of version 5.2.0