I've created an Angular .NET 5 web application and am trying to run npm i
to install the packages. When I do, I get this 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/compiler
npm ERR! @angular/compiler@"13.2.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"13.2.5" from @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"^13.2.3" from the root project
npm ERR! peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^13.2.4" 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\...\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\...\AppData\Local\npm-cache\_logs\2022-03-07T14_52_08_376Z-debug.log
As you can see from my package.json file below, I'm not referencing @angular/[email protected]
or @angular-devkit/[email protected]
. If I were to guess, it's probably attempting to use the global cli version installed which is likely 13.2.5, but why would it completely ignore the one referenced in the package.json? Sure, I could use --force
or --legacy-peer-deps
, but am I really supposed to tell it to ignore dependencies when the correct dependencies are referenced in the package.json? It doesn't make sense to me. I've done an npm cache clean --force
, but that didn't help. What's the "correct" way to handle this scenario assuming I want to use this specific version?
package.json
{
"name": "myapp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run myapp:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "13.2.3",
"@angular/compiler": "13.2.3",
"@angular/core": "13.2.3",
"@angular/forms": "13.2.3",
"@angular/platform-browser": "13.2.3",
"@angular/platform-browser-dynamic": "13.2.3",
"@angular/platform-server": "13.2.3",
"@angular/router": "13.2.3",
"bootstrap": "^4.6.0",
"core-js": "^3.8.3",
"jquery": "^3.5.1",
"oidc-client": "^1.11.3",
"popper.js": "^1.16.0",
"rxjs": "^6.6.3",
"zone.js": "0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.2.4",
"@angular/cli": "^13.2.4",
"@angular/compiler-cli": "^13.2.3",
"@angular/language-service": "^13.2.3",
"@types/jasmine": "~3.4.4",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~12.11.6",
"codelyzer": "^6.0.2",
"ini": "^1.3.7",
"jasmine-core": "3.8",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^6.3.16",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"typescript": "4.5.5"
},
"optionalDependencies": {
"node-sass": "^7.0.1",
"protractor": "^7.0.0",
"ts-node": "~8.4.1",
"tslint": "^6.1.0"
},
"resolutions": {
"url-parse": ">=1.5.0",
"lodash": ">=4.17.21"
}
}
CodePudding user response:
Looks like it is because of the caret ^
which will try to get the minor release. Try by removing the package-lock.json
& remove the caret before the version number.
Alternatively you can also try yarn install