简体   繁体   English

在 angular 9 项目上运行 npm 安装时出错

[英]Error while running npm install on angular 9 project

Angular cli: 9.1.12 Angular cli: 9.1.12
global Angular cli: 14.0.5全球 Angular cli: 14.0.5

When running npm install i got the following error:运行 npm 安装时出现以下错误:

npm ERR! npm 错误! code ERESOLVE代码 ERESOLVE
npm ERR! npm 错误! ERESOLVE unable to resolve dependency tree ERESOLVE 无法解析依赖树
npm ERR! npm 错误!
npm ERR: While resolving. npm ERR:正在解决。 jiffyweb@0.0.0 jiffyweb@0.0.0
npm ERR: Found. npm ERR:找到。 @angular/common@9.1.13 @angular/common@9.1.13
npm ERR! npm 错误! node_modules/@angular/common node_modules/@angular/common
npm ERR. npm 错误。 @angular/common@"~9.1.12" from the root project @angular/common@"~9.1.12" 来自根项目
npm ERR! npm 错误!
npm ERR: Could not resolve dependency: npm ERR:无法解析依赖:
npm ERR. npm 错误。 peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/core@1.1.0来自@agm/core@1.1.0 的对等@angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0"
npm ERR! npm 错误! node_modules/@agm/core节点模块/@agm/核心
npm ERR. npm 错误。 @agm/core@"^1.1.0" from the root project @agm/core@"^1.1.0" 来自根项目
npm ERR! npm 错误!
npm ERR, Fix the upstream dependency conflict, or retry npm ERR,修复上游依赖冲突,或者重试
npm ERR, this command with --force, or --legacy-peer-deps npm ERR,此命令带有--force,或--legacy-peer-deps
npm ERR. npm 错误。 to accept an incorrect (and potentially broken) dependency resolution.接受不正确的(并且可能被破坏的)依赖解决方案。
npm ERR! npm 错误!
npm ERR: See C.\Users\91886\AppData\Local\npm-cache\eresolve-report.txt for a full report. npm ERR:有关完整报告,请参阅 C.\Users\91886\AppData\Local\npm-cache\eresolve-report.txt。
npm ERR: A complete log of this run can be found in: npm ERR:此运行的完整日志可在以下位置找到:
npm ERR: C.\Users\91886\AppData\Local\npm-cache_logs\2022-08-22T13_37_46_059Z-debug-0.log \ npm ERR: C.\Users\91886\AppData\Local\npm-cache_logs\2022-08-22T13_37_46_059Z-debug-0.log \

Here's the package.json file:这是package.json文件:

"dependencies": {
  "@agm/core": "^1.1.0",
  "@angular/animations": "~9.1.12",
  "@angular/cdk": "^10.0.2",
  "@angular/common": "~9.1.12",
  "@angular/compiler": "~9.1.12",
  "@angular/core": "~9.1.12",
  "@angular/forms": "~9.1.12",
  "@angular/platform-browser": "~9.1.12",
  "@angular/platform-browser-dynamic": "~9.1.12",
  "@angular/platform-server": "~9.1.12",
  "@angular/router": "~9.1.12",
  "@kolkov/angular-editor": "^1.1.4",
  "@ng-select/ng-select": "^5.0.9",
  "@nguniversal/express-engine": "^9.1.1",
  "angular-agora-rtc": "^0.1.0",
  "angular-bootstrap-scrolling-tabs": "^1.2.0",
  "angular2-datatable-pagination": "0.0.3",
  "angularx-social-login": "^3.5.7",
  "bootstrap": "^4.5.0",
  "domino": "^2.1.5",
  "express": "^4.15.2",
  "jquery": "^3.5.1",
  "mock-browser": "^0.92.14",
  "moment": "^2.27.0",
  "multiple-date-picker-angular": "^3.0.0",
  "ng-lazyload-image": "^8.0.1",
  "ngx-bootstrap": "^5.6.1",
  "ngx-cookie-service": "^3.0.4",
  "ngx-fs": "0.0.1",
  "ngx-infinite-scroll": "^10.0.1",
  "ngx-quicklink": "^0.2.3",
  "ngx-slick-carousel": "^0.5.1",
  "ngx-toastr": "^13.0.0",
  "popper": "^1.0.1",
  "rxjs": "~6.5.4",
  "slick-carousel": "^1.8.1",
  "socket.io-client": "^3.0.5",
  "ts-overlapping-marker-spiderfier": "^1.0.3",
  "tslib": "^1.10.0",
  "zone.js": "~0.10.2"
},
"devDependencies": {
  "@angular-devkit/build-angular": "~0.901.11",
  "@angular/cli": "~9.1.11",
  "@angular/compiler-cli": "~9.1.12",
  "@nguniversal/builders": "^9.1.1",
  "@types/express": "^4.17.0",
  "@types/node": "^12.11.1",
  "@types/jasmine": "~3.5.0",
  "@types/jasminewd2": "~2.0.3",
  "codelyzer": "^5.1.2",
  "jasmine-core": "~3.5.0",
  "jasmine-spec-reporter": "~4.2.1",
  "karma": "~5.0.0",
  "karma-chrome-launcher": "~3.1.0",
  "karma-coverage-istanbul-reporter": "~2.1.0",
  "karma-jasmine": "~3.0.1",
  "karma-jasmine-html-reporter": "^1.4.2",
  "protractor": "~7.0.0",
  "ts-node": "~8.3.0",
  "tslint": "~6.1.0",
  "typescript": "~3.8.3"
}

This is an error-related dependency conflict version mismatch between direct and indirect dependency with incorrect and broken dependency.这是直接和间接依赖之间的错误相关的依赖冲突版本不匹配,以及不正确和损坏的依赖。

Couple of ways that you can try:您可以尝试以下几种方法:

  1. Follow the below steps:请按照以下步骤操作:
  • Downgrade the npm version to the previous version将npm版本降级到之前的版本
  • remove the node_modules folder删除 node_modules 文件夹
  • remove package-lock.json删除 package-lock.json
  • please do npm install one more time to do a fresh installation of the dependency请再安装一次 npm 以重新安装依赖项
  1. Another way is, Run npm install with –force or –legacy-peer-deps option to set peer dependencies to resolve automatically.另一种方法是,运行 npm install 并使用 –force 或 –legacy-peer-deps 选项设置对等依赖项以自动解析。 npm install --legacy-peer-deps

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM