Search code examples
angularangular-materialangular-cdkangular-flex-layout

The Angular Material version (12.1.4) does not match the Angular CDK version (12.2.1). Please ensure the versions of these two packages exactly match


After installing FlexLayout using this command

npm i -s @angular/flex-layout @angular/cdk

Which obviously install Angular CDK as well, i'm getting the following warning

The Angular Material version (12.1.4) does not match the Angular CDK version (12.2.1).
Please ensure the versions of these two packages exactly match.

I used ng update command in order to update packages, also tried ng add @angular/material, but i'm still with the same versions.

How do I solve this?

SOLUTION

The commands ng add @angular/material & ng add @angular/material@latest works just fine, i checked the package.json file and noticed that i had

"dependencies": {
    ...
    "@angular/material": "^12.2.1"
    ... 
}

it just needed an ng serve again.

And one more thing, It seems like updating Angular Material doesn't really overrides the styles.scss file, but actually adds the same code again to the file, so i had to delete that too in order to get rid of the scss errors.


Solution

  • Try with:

    ng add @angular/material@latest
    

    or

    ng add @angular/[email protected]