当我尝试使用
npx create-react-app my-app
创建反应应用程序时,出现以下错误:
Creating a new React app in /home/aaliyah/temp/amazon_clone/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1323 packages in 10s
267 packages are looking for funding
run `npm fund` for details
Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
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/[email protected]
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 /home/aaliyah/.npm/_logs/2025-01-20T15_10_36_965Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/aaliyah/.npm/_logs/2025-01-20T15_10_36_965Z-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
我已经尝试过
--force
和 --legacy-peer-deps
标志,但它们似乎也不起作用。
我已提示 ChatGPT 20 次,但不起作用。 (尝试使用较旧的 React 版本)这次运行的完整日志没有告诉我任何信息。
有人可以帮我吗? 我正在运行 Linux Mint 并且具有 x86 架构。
谢谢!
有点奇怪。我可以建议您使用另一个模板(例如 vite)。
它不仅更快,而且更容易(在我看来)。
命令是
npm create vite@latest my-app -- --template react
希望对你有帮助!