美文网首页
创建react@19.0.0项目失败解决方案

创建react@19.0.0项目失败解决方案

作者: fatshi | 来源:发表于2024-12-13 12:56 被阅读0次

执行react创建命令

create-react-app my-app

返回失败信息

Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: my-app@0.1.0
npm error Found: react@19.0.0
npm error node_modules/react
npm error   react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @testing-library/react@13.4.0
npm error node_modules/@testing-library/react
npm error   @testing-library/react@"^13.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\Admin\AppData\Local\npm-cache\_logs\2024-12-14T04_49_54_235Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\Users\Admin\AppData\Local\npm-cache\_logs\2024-12-14T04_49_54_235Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

解决办法,降级到react@18:

# 切换到创建项目
cd my-app

# 安装react@18
npm install react@18.0.0 react-dom@18.0.0

# 安装库
npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0

相关文章

网友评论

      本文标题:创建react@19.0.0项目失败解决方案

      本文链接:https://www.haomeiwen.com/subject/eryfejtx.html