SimonZ89
SimonZ89

Reputation: 167

Npm dependency conflict - how to solve it?

I am trying to install graphql-iso-date. Can someone tell me how to fix this?

npm ERR! code ERESOLVE  
npm ERR! ERESOLVE unable to resolve dependency tree  
npm ERR!  
npm ERR! While resolving: undefined@undefined
npm ERR! Found: graphql@16.2.0
npm ERR! node_modules/graphql
npm ERR!   graphql@"^16.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer graphql@"^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" from graphql-iso-date@3.6.1
npm ERR! node_modules/graphql-iso-date
npm ERR!   graphql-iso-date@"*" 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\Simon\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\Simon\AppData\Local\npm-cache\_logs\2022-01-11T19_26_53_815Z-debug-0.log

Upvotes: 5

Views: 15476

Answers (3)

Lin Du
Lin Du

Reputation: 102587

Please be careful to run the npm install <package> with --force, or --legacy-peer-deps option, it will cause potentially broken. Instead, we should fix the version compatibility issues between dependent packages.

Let's check the peerDependencies of graphql-iso-date@3.6.1 package.

$ npm view graphql-iso-date@3.6.1 peerDependencies
{
  graphql: '^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0'
}

This means it demands the graphql package as its peer dependency with these compatibility versions.

Obviously, the graphql@16.2.0 version is not on the list. That's why you got the warning.

The safe solution is to downgrade the graphql package to the compatibility version.

Let's check the all 14.x versions of graphql package:

$ npm view graphql@14 version
graphql@14.0.0 '14.0.0'
graphql@14.0.1 '14.0.1'
graphql@14.0.2 '14.0.2'
graphql@14.1.0 '14.1.0'
graphql@14.1.1 '14.1.1'
graphql@14.2.0 '14.2.0'
graphql@14.2.1 '14.2.1'
graphql@14.3.0 '14.3.0'
graphql@14.3.1 '14.3.1'
graphql@14.4.0 '14.4.0'
graphql@14.4.1 '14.4.1'
graphql@14.4.2 '14.4.2'
graphql@14.5.0 '14.5.0'
graphql@14.5.1 '14.5.1'
graphql@14.5.2 '14.5.2'
graphql@14.5.3 '14.5.3'
graphql@14.5.4 '14.5.4'
graphql@14.5.5 '14.5.5'
graphql@14.5.6 '14.5.6'
graphql@14.5.7 '14.5.7'
graphql@14.5.8 '14.5.8'
graphql@14.6.0 '14.6.0'
graphql@14.7.0 '14.7.0'

We can use the last version of 14.x, it's compatible with ^14.0.0. Now let's downgrade the version of graphql package and install graphql-iso-date package

$ npm i graphql@^14.7.0 -S

added 1 package, changed 1 package, and audited 3 packages in 26s

found 0 vulnerabilities
$ npm i graphql-iso-date -S

added 1 package, and audited 4 packages in 8s

found 0 vulnerabilities

List the installed packages:

$ npm ls --depth 0
peer-deps-issue@ /home/lindu/workspace/peer-deps-issue
├── graphql-iso-date@3.6.1
└── graphql@14.7.0

The warning is gone. Further reading npm-v7-series-beta-release-and-semver-major

Upvotes: 3

Mark Kiprono
Mark Kiprono

Reputation: 9

I tried --legacy-peer-deps but nothing worked for me so I tried Running: npm i -g npm@next-7 and it worked for me.

Upvotes: 0

vishwa
vishwa

Reputation: 74

this has occured because the peer dependencies were conflicting for new versions of npm. the package is not so well maintained.

use --legacy-peer-deps with your command.

exact command would be : npm install graphql-iso-date --legacy-peer-deps

use --save flag if you need.

Upvotes: 2

Related Questions