npm install semantic-ui-react semantic-ui-css npm ERR! code ERESOLVE npm -6ren">
gpt4 book ai didi

javascript - 我无法安装 "npm install semantic-ui-react semantic-ui-css",我该怎么办?

转载 作者:行者123 更新时间:2023-12-05 00:36:57 24 4
gpt4 key购买 nike

C:\reactcamp\camp-project> npm install semantic-ui-react semantic-ui-css
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: camp-project@0.1.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0" from semantic-ui-react@2.1.2
npm ERR! node_modules/semantic-ui-react
npm ERR! semantic-ui-react@"^2.1.2" 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\zekis\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\zekis\AppData\Local\npm-cache\_logs\2022-05-01T18_07_14_536Z-debug-0.log

最佳答案

TLDR:semantic-ui-react@2.1.2incompatible with React 18 .作为一种解决方法,您可以将应用程序降级到 react 17 .
解决时:camp-project@0.1.0

npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
前三行表明 npm 识别了 react 18 作为您项目的依赖项。
无法解决依赖关系
npm ERR! peer react@"^16.8.0 || ^17.0.0" from semantic-ui-react@2.1.2
npm ERR! node_modules/semantic-ui-react
npm ERR! semantic-ui-react@"^2.1.2" from the root project
这 3 行列出了 semantic-ui-react的对等依赖,这意味着它希望您的项目具有 react 16.8 react 17 作为依赖。
修复上游依赖冲突
有两种方法可以解决这种冲突:
  • 将您的项目降级到 react 17 使用 npm install react@17
  • 覆盖 semantic-ui-react使用 yarn 的Selective Resolution feature .在你的 package.json 中:
  • "resolutions": {
    "semantic-ui-react/react": "^18.0.0"
    }

    关于javascript - 我无法安装 "npm install semantic-ui-react semantic-ui-css",我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72079344/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com