安装时出现问题react@18-为什么我不能安装软件包



我无法安装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
}

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

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

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

也许有人有解决方案:(

非常感谢!!!

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

您可以尝试以下操作:

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

最新更新