无法解决运行"npm i @angular/cdk"命令的依赖关系树错误



我想运行这个命令

npm i @angular/cdk

我得到了这个错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: angular-osm@0.0.0
npm ERR! Found: zone.js@0.11.4
npm ERR! node_modules/zone.js
npm ERR!   zone.js@"~0.11.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js@"~0.10.3" from @angular/core@10.1.6
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"~10.1.2" from the root project
npm ERR!   peer @angular/core@"10.1.6" from @angular/common@10.1.6
npm ERR!   node_modules/@angular/common
npm ERR!   @angular/common@"~10.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.

我去除了node_modules,运行了npm installnpm auditnpm audit fixnpm i --legacy-peer-deps。我还更新了";茉莉花心";至‘~3.6.0’。角度版本:"10.1.2"节点版本:"16.13.0"NPM版本:"8.1.4">

这是我的package.json文件:

{
"name": "angular-osm",
"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": "~10.1.2",
"@angular/common": "~10.1.2",
"@angular/compiler": "~10.1.2",
"@angular/core": "~10.1.2",
"@angular/forms": "~10.1.2",
"@angular/platform-browser": "~10.1.2",
"@angular/platform-browser-dynamic": "~10.1.2",
"@angular/router": "~10.1.2",
"@asymmetrik/ngx-leaflet": "^8.1.0",
"@types/leaflet": "^1.5.17",
"angular-bootstrap-md": "^12.1.0",
"jquery": "^3.6.0",
"leaflet": "^1.7.1",
"rxjs": "~6.6.3",
"tslib": "^2.0.1",
"zone.js": "~0.11.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.2",
"@angular/cli": "~10.1.2",
"@angular/compiler-cli": "~10.1.2",
"@types/jasmine": "~3.5.14",
"@types/jasminewd2": "~2.0.8",
"@types/jquery": "^3.5.9",
"@types/node": "^14.11.2",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~6.0.0",
"karma": "~5.2.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "~7.0.0",
"ts-node": "~9.0.0",
"tslint": "~6.1.0",
"typescript": "~4.0.3"}
}

我在不同的库中遇到了同样的问题。我使用的是最新的npm版本。那是我的问题。所以我不得不降级npm版本。我安装了node-v14.19.0(npm版本-6.14.16(。它对我有效。

相关内容

最新更新