Could not resolve dependency conflict among @angular/cdk, @angular/core and @angular-material-components/datetime-picker

1k Views Asked by At

I'm developing an angular app in which I use Angular-Material. I want to use matdatetimepicker in a form field. I performed some google searches and realized that, I need to install Material Datepicker & Timepicker Package with the npm command `

$ npm install @angular-material-components/datetime-picker

But npm keeps throwing the following errors:

$ npm install @angular-material-components/datetime-picker
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/cdk
npm ERR!   @angular/cdk@"^13.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/cdk@"^15.0.1" from @angular-material-components/[email protected]
npm ERR! node_modules/@angular-material-components/datetime-picker
npm ERR!   @angular-material-components/datetime-picker@"*" 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.
npm ERR!
npm ERR! See C:\Users\jsabrokwah\AppData\Local\npm-cache\eresolve-report.txt for a full report.    

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jsabrokwah\AppData\Local\npm-cache\_logs\2022-12-19T10_59_17_667Z-debug-0.log

I then consulted the documentation and realized I have to install datetime-picker version 7 in ensure compatibility with @angular/cdk@"^13.0.0".

So I went ahead to issue the commant; $ npm install @angular-material-components/[email protected] and npm keeps throwing the following error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]        
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^14.2.0" from the root project
npm ERR!   peer @angular/common@"^13.0.0 || ^14.0.0-0" from @angular/[email protected]
npm ERR!   node_modules/@angular/cdk
npm ERR!     @angular/cdk@"^13.0.0" from the root project
npm ERR!     peer @angular/cdk@"^13.0.1" from @angular-material-components/[email protected]
npm ERR!     node_modules/@angular-material-components/datetime-picker
npm ERR!       @angular-material-components/datetime-picker@"7.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^13.0.1" from @angular-material-components/[email protected] 
npm ERR! node_modules/@angular-material-components/datetime-picker
npm ERR!   @angular-material-components/datetime-picker@"7.0" 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.
npm ERR!
npm ERR! See C:\Users\jsabrokwah\AppData\Local\npm-cache\eresolve-report.txt for a full report.    

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jsabrokwah\AppData\Local\npm-cache\_logs\2022-12-19T11_07_34_825Z-debug-0.log

I am stack and don't know what to do...

Here is my package-lock.json file;

"packages": {
    "": {
      "name": "deywuro-app",
      "version": "0.0.0",
      "dependencies": {
        "@angular/animations": "^14.2.0",
        "@angular/cdk": "^13.0.0",
        "@angular/common": "^14.2.0",
        "@angular/compiler": "^14.2.0",
        "@angular/core": "^14.2.0",
        "@angular/forms": "^14.2.0",
        "@angular/material": "^13.0.0",
        "@angular/platform-browser": "^14.2.0",
        "@angular/platform-browser-dynamic": "^14.2.0",
        "@angular/router": "^14.2.0",
        "@fortawesome/fontawesome-free": "^6.2.1",
        "rxjs": "~7.5.0",
        "tslib": "^2.3.0",
        "zone.js": "~0.11.4"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "^14.2.7",
        "@angular/cli": "~14.2.7",
        "@angular/compiler-cli": "^14.2.0",
        "@types/jasmine": "~4.0.0",
        "jasmine-core": "~4.3.0",
        "karma": "~6.4.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.2.0",
        "karma-jasmine": "~5.1.0",
        "karma-jasmine-html-reporter": "~2.0.0",
        "typescript": "~4.7.2"
      }
    }

And my package.json file:

{
  "name": "deywuro-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.2.0",
    "@angular/cdk": "^13.0.0",
    "@angular/common": "^14.2.0",
    "@angular/compiler": "^14.2.0",
    "@angular/core": "^14.2.0",
    "@angular/forms": "^14.2.0",
    "@angular/material": "^13.0.0",
    "@angular/platform-browser": "^14.2.0",
    "@angular/platform-browser-dynamic": "^14.2.0",
    "@angular/router": "^14.2.0",
    "@fortawesome/fontawesome-free": "^6.2.1",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.7",
    "@angular/cli": "~14.2.7",
    "@angular/compiler-cli": "^14.2.0",
    "@types/jasmine": "~4.0.0",
    "jasmine-core": "~4.3.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.7.2"
  }
}

I've consulted several blogs and similar problems on stackoverflow

But npm keeps throwing same errors

0

There are 0 best solutions below