【问题标题】:Problem installing react@18 - why can I not install the package?安装 react@18 时出现问题 - 为什么我无法安装软件包?
【发布时间】:2022-06-12 13:07:05
【问题描述】:

我无法安装 react@18,因为我收到以下错误

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "current": {
    "name": "react",
    "version": "18.0.0",
    "whileInstalling": {
      "name": "cap",
      "version": "0.1.0",
      "path": "/Users/dheld/pollopi/cap"
    },
    "location": "node_modules/react",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "prod",
        "name": "react",
        "spec": "^18.0.0",
        "from": {
          "location": "/Users/dheld/pollopi/cap"
        }
      }
    ]
  },
  "currentEdge": {
    "type": "prod",
    "name": "react",
    "spec": "^18.0.0",
    "from": {
      "location": "/Users/dheld/pollopi/cap"
    }
  },
  "edge": {
    "type": "peer",
    "name": "react",
    "spec": "<18.0.0",
    "error": "INVALID",
    "from": {
      "name": "@testing-library/react",
      "version": "12.1.5",
      "whileInstalling": {
        "name": "cap",
        "version": "0.1.0",
        "path": "/Users/dheld/pollopi/cap"
      },
      "location": "node_modules/@testing-library/react",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "prod",
          "name": "@testing-library/react",
          "spec": "^12.0.0",
          "from": {
            "location": "/Users/dheld/pollopi/cap"
          }
        }
      ]
    }
  },
  "strictPeerDeps": false,
  "force": false
}

我已经尝试在全局和文件夹中安装@testing-library/react,但两者都不起作用

React 16 我可以毫无问题地安装

您在代码段中看到的是文件 eresolve-report.txt 的输出

也许有人有解决方案:)

非常感谢!!!

【问题讨论】:

    标签: reactjs


    【解决方案1】:

    我从错误消息中了解到,@testing-library/react 包需要 18 之前的 React 版本。所以你不能安装 React 18,至少在测试库不支持的情况下。

    【讨论】:

      【解决方案2】:

      我对 react 18 也有同样的问题。解决者:-

      npm install react-html-parser --legacy-peer-deps
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多