1

Every now and then I see dependency conflicts. The only answers I find (and which are suggested in the cmd output) is to use "--legacy-peer-deps", but how do I solve the dependency conflict rather than avoiding it? In this case I want to install a package, but it doesn't seem to install the package because of my dependency conflicts.

npm i @react-native-community/cli
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @radix-ui/react-accordion@0.1.6
npm WARN Found: react@18.1.0
npm WARN node_modules/react
npm WARN   peer react@">= 16.8.0" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN     @aws-amplify/ui-react@"^2.8.0" from the root project
npm WARN   74 more (@aws-amplify/ui-react-v1, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8 || ^17.0" from @radix-ui/react-accordion@0.1.6
npm WARN node_modules/@radix-ui/react-accordion
npm WARN   @radix-ui/react-accordion@"0.1.6" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^16.8 || ^17.0" from @radix-ui/react-accordion@0.1.6
npm WARN   node_modules/@radix-ui/react-accordion
npm WARN     @radix-ui/react-accordion@"0.1.6" from @aws-amplify/ui-react@2.20.0
npm WARN     node_modules/@aws-amplify/ui-react
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @radix-ui/react-arrow@0.1.4
npm WARN Found: react@18.1.0
npm WARN node_modules/react
npm WARN   peer react@">= 16.8.0" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN     @aws-amplify/ui-react@"^2.8.0" from the root project
npm WARN   74 more (@aws-amplify/ui-react-v1, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8 || ^17.0" from @radix-ui/react-arrow@0.1.4
npm WARN node_modules/@radix-ui/react-arrow
npm WARN   @radix-ui/react-arrow@"0.1.4" from @radix-ui/react-popper@0.1.4
npm WARN   node_modules/@radix-ui/react-popper
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^16.8 || ^17.0" from @radix-ui/react-arrow@0.1.4
npm WARN   node_modules/@radix-ui/react-arrow
npm WARN     @radix-ui/react-arrow@"0.1.4" from @radix-ui/react-popper@0.1.4
npm WARN     node_modules/@radix-ui/react-popper
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @radix-ui/react-collapsible@0.1.6
npm WARN Found: react@18.1.0
npm WARN node_modules/react
npm WARN   peer react@">= 16.8.0" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN     @aws-amplify/ui-react@"^2.8.0" from the root project
npm WARN   74 more (@aws-amplify/ui-react-v1, ...)
npm WARN (@aws-amplify/ui-react-v1, ...)
npm WARN
.........................
.........................
.........................
.........................
.........................
npm WARN While resolving: @radix-ui/react-use-rect@0.1.1
npm WARN Found: react@18.1.0
npm WARN node_modules/react
npm WARN   peer react@">= 16.8.0" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN     @aws-amplify/ui-react@"^2.8.0" from the root project
npm WARN   74 more (@aws-amplify/ui-react-v1, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8 || ^17.0" from @radix-ui/react-use-rect@0.1.1
npm WARN node_modules/@radix-ui/react-use-rect
npm WARN   @radix-ui/react-use-rect@"0.1.1" from @radix-ui/react-popper@0.1.4
npm WARN   node_modules/@radix-ui/react-popper
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^16.8 || ^17.0" from @radix-ui/react-use-rect@0.1.1
npm WARN   node_modules/@radix-ui/react-use-rect
npm WARN     @radix-ui/react-use-rect@"0.1.1" from @radix-ui/react-popper@0.1.4
npm WARN     node_modules/@radix-ui/react-popper
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @radix-ui/react-use-size@0.1.1
npm WARN Found: react@18.1.0
npm WARN node_modules/react
npm WARN   peer react@">= 16.8.0" from @aws-amplify/ui-react@2.20.0
npm WARN   node_modules/@aws-amplify/ui-react
npm WARN     @aws-amplify/ui-react@"^2.8.0" from the root project
npm WARN   74 more (@aws-amplify/ui-react-v1, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8 || ^17.0" from @radix-ui/react-use-size@0.1.1
npm WARN node_modules/@radix-ui/react-use-size
npm WARN   @radix-ui/react-use-size@"0.1.1" from @radix-ui/react-popper@0.1.4
npm WARN   node_modules/@radix-ui/react-popper
npm WARN   1 more (@radix-ui/react-slider)
npm WARN
npm WARN Conflicting peer dependency: react@17.0.2
npm WARN node_modules/react
npm WARN   peer react@"^16.8 || ^17.0" from @radix-ui/react-use-size@0.1.1
npm WARN   node_modules/@radix-ui/react-use-size
npm WARN     @radix-ui/react-use-size@"0.1.1" from @radix-ui/react-popper@0.1.4
npm WARN     node_modules/@radix-ui/react-popper
npm WARN     1 more (@radix-ui/react-slider)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @react-native-community/eslint-config@3.2.0
npm ERR! Found: eslint@7.32.0
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^7.5.0 || ^8.0.0" from @babel/eslint-parser@7.19.1
npm ERR!   node_modules/@babel/eslint-parser
npm ERR!     @babel/eslint-parser@"^7.18.2" from @react-native-community/eslint-config@3.2.0
npm ERR!     node_modules/@react-native-community/eslint-config
npm ERR!       dev @react-native-community/eslint-config@"^3.0.1" from the root project
npm ERR!     peer @babel/eslint-parser@"^7.12.0" from eslint-plugin-ft-flow@2.0.3
npm ERR!     node_modules/eslint-plugin-ft-flow
npm ERR!       eslint-plugin-ft-flow@"^2.0.1" from @react-native-community/eslint-config@3.2.0
npm ERR!       node_modules/@react-native-community/eslint-config
npm ERR!         dev @react-native-community/eslint-config@"^3.0.1" from the root project
npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/eslint-plugin@5.43.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     @typescript-eslint/eslint-plugin@"^5.30.5" from @react-native-community/eslint-config@3.2.0
npm ERR!     node_modules/@react-native-community/eslint-config
npm ERR!       dev @react-native-community/eslint-config@"^3.0.1" from the root project
npm ERR!     peerOptional @typescript-eslint/eslint-plugin@"^5.0.0" from eslint-plugin-jest@26.9.0
npm ERR!     node_modules/eslint-plugin-jest
npm ERR!       eslint-plugin-jest@"^26.5.3" from @react-native-community/eslint-config@3.2.0
npm ERR!       node_modules/@react-native-community/eslint-config
npm ERR!         dev @react-native-community/eslint-config@"^3.0.1" from the root project
npm ERR!   22 more (@typescript-eslint/experimental-utils, eslint-utils, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">=8" from @react-native-community/eslint-config@3.2.0
npm ERR! node_modules/@react-native-community/eslint-config
npm ERR!   dev @react-native-community/eslint-config@"^3.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: eslint@8.27.0
npm ERR! node_modules/eslint
npm ERR!   peer eslint@">=8" from @react-native-community/eslint-config@3.2.0
npm ERR!   node_modules/@react-native-community/eslint-config
npm ERR!     dev @react-native-community/eslint-config@"^3.0.1" 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.
bieboebap
  • 320
  • 3
  • 18

1 Answers1

0
  1. Try to install the latest version of the packages that create the problem, with npm i packageName@latest --force.

If that doesn't solve it.

  1. Uninstall the packages and install other that do the same job, with --force.

Otherwise:

  1. You may need to downgrade React to a version compatible with the package.

Attention!

--force and --legacy-peer-deps should be used carefully...

Fotios Tsakiris
  • 1,310
  • 1
  • 18
  • 24