我经常看到依赖性冲突。我找到的唯一答案(也是cmd输出中建议的)是使用“--legacy-peer-deps”,但是我如何解决依赖冲突而不是避免它呢?在本例中,我想安装一个软件包,但由于我的依赖项冲突,它似乎没有安装该软件包。
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.
1条答案
按热度按时间ev7lccsx1#
1.请尝试安装导致问题的软件包的最新版本,即
npm i packageName@latest --force
。如果这还不能解决问题的话。
1.卸载软件包并安装其他执行相同工作的软件包,使用
--force
。否则:
1.您可能需要将React降级到与包兼容的版本。
立正!
--force
和--legacy-peer-deps
应谨慎使用。