Skip to content

Support using Angular CDK & Material v16 in Angular v18 #29440

@mlc-mlapis

Description

@mlc-mlapis

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Any Angular v17 version.

Description

The peerDependencies sections in the package.json file for Angular CDK v16.2.14 and Angular Material v16.2.14 specify only @angular v16 or v17. However, there is declared official support for running Material M2, even in Angular v18. To allow it, it's necessary to add ^18.0.0 for all Angular packages in the peerDependencies sections of Angular CDK v16 and Angular Material v16.

// Angular CDK 16.2.14
"peerDependencies": {
    "@angular/core": "^16.0.0 || ^17.0.0",
    "@angular/common": "^16.0.0 || ^17.0.0",
    "rxjs": "^6.5.3 || ^7.4.0"
}
// Angular Material 16.2.14
"peerDependencies": {
    "@angular/animations": "^16.0.0 || ^17.0.0",
    "@angular/cdk": "16.2.14",
    "@angular/core": "^16.0.0 || ^17.0.0",
    "@angular/common": "^16.0.0 || ^17.0.0",
    "@angular/forms": "^16.0.0 || ^17.0.0",
    "@angular/platform-browser": "^16.0.0 || ^17.0.0",
    "rxjs": "^6.5.3 || ^7.4.0"
}

Using the --legacy-peer-deps flag is not the ideal solution because it also affects the installation of all other packages.

Expected Behavior

Allow using Angular CDK v16 and Angular Material v16 together with Angular v18.

Actual Behavior

When running the npm i command (Angular v18 environment), the following resolve problem appears:

Could not resolve dependency:
npm error peer @angular/common@"^16.0.0 || ^17.0.0" from @angular/cdk@16.2.14
npm error node_modules/@angular/cdk
npm error @angular/cdk@"16.2.14" from the root project

Environment

  • Angular: 18.1.0
  • CDK/Material: 16.2.14
  • Browser(s): Chrome, FF
  • Operating System: Windows, macOS, Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions