Conflict in dependency resolution when installing @angular/cdk@16.0.2

341 views
Skip to first unread message

Leonel Salcedo

unread,
Jun 2, 2023, 10:19:59 AM6/2/23
to angular-material2
Description

I am experiencing a dependency conflict while trying to install @angular/c...@16.0.2 in an Angular project. The project currently has the following dependencies:

"dependencies": { "@angular/animations": "^16.1.0-next.2", "@angular/common": "^16.1.0-next.2", "@angular/compiler": "^16.1.0-next.2", "@angular/core": "^16.1.0-next.2", "@angular/forms": "^16.1.0-next.2", "@angular/platform-browser": "^16.1.0-next.2", "@angular/platform-browser-dynamic": "^16.1.0-next.2", "@angular/router": "^16.1.0-next.2", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.13.0" }
When I try to install @angular/cdk using the command ng add @angular/c...@16.0.2, I receive the following error:

The package @angular/c...@16.0.2 will be installed and executed. Would you like to proceed? Yes npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: ga...@0.0.0 npm ERR! Found: @angular/com...@16.1.0-next.2 npm ERR! node_modules/@angular/common npm ERR! @angular/common@"^16.1.0-next.2" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/common@"^16.0.0 || ^17.0.0" from @angular/c...@16.0.2 npm ERR! node_modules/@angular/cdk npm ERR! @angular/cdk@"16.0.2" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Reproduction

Steps to reproduce:

  1. Create an Angular project.
  2. Run the command ng add @angular/cdk.
  3. Run the command npm update.
  4. Run the command npm install.
  5. Run the command ng add @angular/cdk --legacy-peer-deps
  6. Run the command ng add @angular/cdk --force.
Expected Behavior

I expect @angular/c...@16.0.2 to be installed without any dependency conflicts, considering the specified versions of the other Angular dependencies.

Actual Behavior

The installation fails with the error message mentioned above.

Environment
  • Angular: ^16.1.0-next.2
  • CDK/Material: @angular/cdk@"16.0.2
  • Browser(s): N/A
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

    Log Files:
    # npm resolution error report

    While resolving: undefined@undefined
    Found: @angular/co...@16.1.0-next.3
    node_modules/@angular/core
      peer @angular/core@"16.1.0-next.3" from @angular/anima...@16.1.0-next.3
      node_modules/@angular/animations
        peerOptional @angular/animations@"16.1.0-next.3" from @angular/platform...@16.1.0-next.3
        node_modules/@angular/platform-browser
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/fo...@16.1.0-next.3
          node_modules/@angular/forms
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
          node_modules/@angular/platform-browser-dynamic
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/rou...@16.1.0-next.3
          node_modules/@angular/router
      peer @angular/core@"16.1.0-next.3" from @angular/com...@16.1.0-next.3
      node_modules/@angular/common
        peer @angular/common@"16.1.0-next.3" from @angular/fo...@16.1.0-next.3
        node_modules/@angular/forms
        peer @angular/common@"16.1.0-next.3" from @angular/platform...@16.1.0-next.3
        node_modules/@angular/platform-browser
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/fo...@16.1.0-next.3
          node_modules/@angular/forms
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
          node_modules/@angular/platform-browser-dynamic
          peer @angular/platform-browser@"16.1.0-next.3" from @angular/rou...@16.1.0-next.3
          node_modules/@angular/router
        peer @angular/common@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
        node_modules/@angular/platform-browser-dynamic
        peer @angular/common@"16.1.0-next.3" from @angular/rou...@16.1.0-next.3
        node_modules/@angular/router
      peerOptional @angular/core@"16.1.0-next.3" from @angular/comp...@16.1.0-next.3
      node_modules/@angular/compiler
        peer @angular/compiler@"16.1.0-next.3" from @angular/compil...@16.1.0-next.3
        node_modules/@angular/compiler-cli
          peer @angular/compiler-cli@"^16.0.0 || ^16.1.0-next.0" from @angular-devkit/build-...@16.1.0-next.2
          node_modules/@angular-devkit/build-angular
          peer @angular/compiler-cli@"^16.0.0 || ^16.1.0-next.0" from @ngtools/web...@16.1.0-next.2
          node_modules/@ngtools/webpack
            @ngtools/webpack@"16.1.0-next.2" from @angular-devkit/build-...@16.1.0-next.2
            node_modules/@angular-devkit/build-angular
        peer @angular/compiler@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
        node_modules/@angular/platform-browser-dynamic
      peer @angular/core@"16.1.0-next.3" from @angular/fo...@16.1.0-next.3
      node_modules/@angular/forms
      peer @angular/core@"16.1.0-next.3" from @angular/platform...@16.1.0-next.3
      node_modules/@angular/platform-browser
        peer @angular/platform-browser@"16.1.0-next.3" from @angular/fo...@16.1.0-next.3
        node_modules/@angular/forms
        peer @angular/platform-browser@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
        node_modules/@angular/platform-browser-dynamic
        peer @angular/platform-browser@"16.1.0-next.3" from @angular/rou...@16.1.0-next.3
        node_modules/@angular/router
      peer @angular/core@"16.1.0-next.3" from @angular/platform-bro...@16.1.0-next.3
      node_modules/@angular/platform-browser-dynamic
      peer @angular/core@"16.1.0-next.3" from @angular/rou...@16.1.0-next.3
      node_modules/@angular/router

    Could not resolve dependency:
    @angular/cdk@"16.0.3" from the root project

    Conflicting peer dependency: @angular/co...@16.0.4
    node_modules/@angular/core
      peer @angular/core@"^16.0.0 || ^17.0.0" from @angular/c...@16.0.3
      node_modules/@angular/cdk
        @angular/cdk@"16.0.3" from the root project

    Fix the upstream dependency conflict, or retry
    this command with --force or --legacy-peer-deps
    to accept an incorrect (and potentially broken) dependency resolution.
Reply all
Reply to author
Forward
0 new messages