I created project using "ng new proj". Below is the package.json file created. ng serve is also working fine. When i run npm install ngx-contextmenu @angular/cdk, its failing with below error. Can someone please suggest how to fix below error, based on error, i tried to go with @angular/common@12, but its giving problem in some other module etc.
npm install ngx-contextmenu @angular/cdk
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@"~11.0.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^12.0.0 || ^13.0.0-0" from @angular/[email protected]
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"*" 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.
package.json:
{
"name": "proj",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.0.6",
"@angular/common": "~11.0.6",
"@angular/compiler": "~11.0.6",
"@angular/core": "~11.0.6",
"@angular/forms": "~11.0.6",
"@angular/platform-browser": "~11.0.6",
"@angular/platform-browser-dynamic": "~11.0.6",
"@angular/router": "~11.0.6",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.6",
"@angular/cli": "~11.0.6",
"@angular/compiler-cli": "~11.0.6",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
CodePudding user response:
The newest version of @angular/cdk
requires which you try to fetch by ommiting required version, requires @angular/common@"^12.0.0 || ^13.0.0-0"
while you have locked that dependency to major version 11 via"@angular/common": "~11.0.6",
Either specify lower version of cdk
or upgrade all dependencies.
CodePudding user response:
You are trying to install a version that depends to Angular 12
You have to install the sdk compatibile with the correct Angular Version (I can see you are using Angular 11).
Try
npm install [email protected]