首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到react 18会导致包依赖错误。

升级到react 18会导致包依赖错误。
EN

Stack Overflow用户
提问于 2022-08-04 16:55:27
回答 1查看 1.1K关注 0票数 0

我有以下package.json文件:

代码语言:javascript
复制
{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.10.0",
    "@emotion/styled": "^11.10.0",
    "@fontsource/roboto": "^4.5.7",
    "@mui/icons-material": "^5.8.4",
    "@mui/lab": "^5.0.0-alpha.93",
    "@mui/material": "^5.9.3",
    "@reduxjs/toolkit": "^1.8.3",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "animate.css": "^4.1.1",
    "generate-password-browser": "^1.1.0",
    "notistack": "^2.0.5",
    "query-string": "^7.1.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.2",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1",
    "string-to-color": "^2.2.2",
    "stylis-plugin-rtl": "^2.1.1",
    "traverse": "^0.6.6",
    "typed.js": "^2.0.12",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我已经创建了这个项目使用创建-反应-应用程序刚才,所以一切都是干净和新的,我只安装了额外的软件包。

现在,我想安装以下软件包:

本周的下载量超过26万次,

代码语言:javascript
复制
$ npm i react-swipeable-views

我得到了一个错误:

代码语言:javascript
复制
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: web@0.1.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.3.0 || ^16.0.0 || ^17.0.0" from react-swipeable-views@0.14.0
npm ERR! node_modules/react-swipeable-views
npm ERR!   react-swipeable-views@"*" 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 /home/sam/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/sam/.npm/_logs/2022-08-04T16_50_51_600Z-debug-0.log

所有的一切都很好,就在我们开始反应之前。谢谢react,现在我该怎么解决这个问题呢?由于这个错误,我还有几十个其他的依赖项无法安装,我能够拯救package.json文件中列出的这些依赖项,谢天谢地。

如果我想回滚回react@17,我不能这样做,因为create-react-app没有这样的选项,因为您无法这样做,如果您的npm un reactnpm i react@17仍然存在错误,因为create-react-app安装了其他依赖项,而不仅仅是react

有什么帮助来摆脱这个问题吗?

    • 如果可能的话,解释一下为什么会这样。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-04 17:04:58

国家预防机制错误!对等反应@“^15.3.0\x\x{e76f}\{e76f}\{e76f}{##**$$}}17.0.0

那个图书馆18岁时还不支持任何东西。根据这个项目,github 问题所在今年已经开通了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73239681

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档