简体   繁体   English

Npm 安装失败(无法解决依赖关系)

[英]Npm Install is Failing (Could not resolve dependency)

When i try to do npm install i get the following 

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: foliosure@1.0.1
npm ERR! Found: zone.js@0.8.29
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/core@7.2.16
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 primeng_latest@11.2.3
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 primeng_latest@11.2.3
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

**Please suggest a solution to resolve this error, Thank you in advance.**

**Dependencies in 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"
  

I have only 3 months experience in angular, I tried downgrading the versions but it still gave error also tried to google the solution but didnt find the right solution, would appreciate any help, Thank you.我在 angular 方面只有 3 个月的经验,我尝试降级版本但它仍然给出错误也尝试谷歌解决方案但没有找到正确的解决方案,不胜感激,谢谢。

Looks like it's a problem with Peer Dependencies try with npm install --legacy-peer-deps .看起来这是对等依赖项的问题,尝试使用 npm install --legacy-peer-deps

You can skip peer dependency conflict checks by running npm install --legacy-peer-deps or you can set npm config set legacy-peer-deps true and then run npm install once again.您可以通过运行npm install --legacy-peer-deps跳过对等依赖冲突检查,或者您可以设置npm config set legacy-peer-deps true然后再次运行npm install

If you want to run the angular code of your friend in your machine then follow the steps.如果您想在您的机器上运行您朋友的 angular 代码,请按照以下步骤操作。

step 1: this can be happen due to version mismatch in your node version and your friends node version and npm version.第 1 步:这可能是由于您的节点版本与您的朋友节点版本和 npm 版本中的版本不匹配而发生的。 C://projectFolder> node --version then C://projectFolder> npm -v C://projectFolder> 节点 --version 然后 C://projectFolder> npm -v

step 2: If the version is mismatch then uninstall node in your machine then restart then install the node version of your friend.第 2 步:如果版本不匹配,则在您的机器中卸载节点,然后重新启动,然后安装您朋友的节点版本。

step 3: run the below code example第 3 步:运行以下代码示例

1. 1.

npm install npm@[version]

in my machine在我的机器里

npm install -g npm@6.2.0
  1. now run npm install in your project folder现在运行 npm 安装在您的项目文件夹中

    npm install npm安装

  2. now npm start or ng serve to work perfectly现在 npm 启动或 ng 服务完美工作

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

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