NodeJS Npm安装失败(无法解析依赖项)

vs91vp4v  于 11个月前  发布在  Node.js
关注(0)|答案(3)|浏览(172)

当我尝试执行npm install时,我得到以下结果:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/zone.js
npm ERR!   zone.js@"~0.8.26" from the root project
npm ERR!   peer zone.js@"~0.8.26" from @angular/[email protected]
npm ERR!   node_modules/@angular/core
npm ERR!     @angular/core@"~7.2.0" from the root project
npm ERR!     peer @angular/core@"^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0" from [email protected]
npm ERR!     node_modules/primeng_latest
npm ERR!       primeng_latest@"npm:primeng@^11.2.0" from the root project
npm ERR!     3 more (@angular/common, @angular/forms, @angular/platform-browser)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js@"^0.10.2" from [email protected]
npm ERR! node_modules/primeng_latest
npm ERR!   primeng_latest@"npm:primeng@^11.2.0" 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

字符串
这是我的package.json依赖文件:

"dependencies": 
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "^7.2.4",
    "@angular/material": "^7.3.7",
    "@angular/router": "~7.2.0",
    "@types/d3": "^5.7.2",
    "bootstrap": "^4.4.1",
    "codemirror": "^5.58.2",
    "file-saver": "^2.0.0",
    "font-awesome": "^4.7.0",
    "highcharts": "^9.0.0",
    "material-design-icons": "^3.0.1",
    "moment": "^2.24.0",
    "ngx-spinner": "^7.2.0",
    "ngx-toastr": "^9.2.0",
    "primeicons": "^1.0.0",
    "primeng": "^7.0.5",
    "primeng_latest": "npm:primeng@^11.2.0",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.26"


我试图降级的版本,但它仍然给出了错误.我也试图谷歌的解决方案,但没有找到正确的解决方案,将感谢任何帮助,谢谢.

jgzswidk

jgzswidk1#

看起来这是一个问题,与对等的重复尝试与npm安装--legacy-peer-deps

piztneat

piztneat2#

您可以通过运行npm install --legacy-peer-deps来跳过对等依赖项冲突检查,也可以设置npm config set legacy-peer-deps true,然后再次运行npm install

dzhpxtsq

dzhpxtsq3#

如果你想在你的机器上运行你朋友的angular代码,那么按照下面的步骤操作。
第一步:这可能是由于您节点版本与您的朋友节点版本和npm版本不匹配而导致的。C://projectFolder> node --version然后C://projectFolder> npm -v
第2步:如果版本不匹配,请卸载您机器中的节点,然后重新启动,然后安装您朋友的节点版本。
步骤3:运行下面的代码示例
1.

npm install npm@[version]

字符串
在我的机器里

npm install -g [email protected]


1.现在运行npm安装在你的项目文件夹
npm install
1.现在npm start或ng可以完美地工作了

相关问题