I have an Angular 7 project, and recently when I run npm install
in my project I get this 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/core
npm ERR! @angular/core@"~7.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^9.0.0 || ^10.0.0-0" from @angular/material-moment- [email protected]
npm ERR! node_modules/@angular/material-moment-adapter
npm ERR! @angular/material-moment-adapter@"^9.1.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.
npm ERR!
npm ERR! See /home/userName/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/userName/.npm/_logs/2021-05-07T13_24_16_492Z-debug.log
It is a big project and I don’t know how to resolve this package conflict. Here is my package.json file:
{
"name": "mat-silabo",
"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": "~7.1.0",
"@angular/cdk": "~7.3.6",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "~7.1.0",
"@angular/material": "^7.3.6",
"@angular/material-moment-adapter": "^9.1.2",
"@angular/platform-browser": "~7.1.0",
"@angular/platform-browser-dynamic": "~7.1.0",
"@angular/router": "~7.1.0",
"core-js": "^2.5.4",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"jspdf": "^1.5.3",
"moment": "^2.24.0",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"xlsx": "^0.16.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.11.0",
"@angular/cli": "~7.1.3",
"@angular/compiler-cli": "~7.1.0",
"@angular/language-service": "~7.1.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}
OS : Debian 10
Global Angular version : 11
If you need any other details please let me know. I am tired of this package dependency, and I want the project to be clean, so we can install it without npm install --force
thanks
2
Answers
It seems
"@angular/material-moment-adapter": "^9.1.2",
wants Angular 9 and you have Angular 7. Change this package to"@angular/material-moment-adapter": "~7.1.0",
and do a freshnpm install
. That should hopefully fix it.The compiler is complaining that it can’t resolve @angular/core 9/10 which is a peer dependency of @angular/material-moment-adapter.
If you are upgrading to Angular 7, you should roll back this dependency to :
"@angular/material-moment-adapter": "~7.3.7"