darksoul@Ronits-MacBook-Air ~ % create-react-app --version
5.0.1
darksoul@Ronits-MacBook-Air ~ % react --version
zsh: command not found: react
darksoul@Ronits-MacBook-Air ~ % node --v
node: bad option: --v
darksoul@Ronits-MacBook-Air ~ % node -v
v22.12.0
darksoul@Ronits-MacBook-Air ~ % create-react-app hello
Creating a new React app in /Users/darksoul/hello.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1314 packages in 38s
261 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
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 /Users/darksoul/.npm/_logs/2024-12-06T07_30_06_577Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/darksoul/.npm/_logs/2024-12-06T07_30_06_577Z-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
darksoul@Ronits-MacBook-Air ~ % node -v
v22.12.0
darksoul@Ronits-MacBook-Air ~ % npm -v
10.9.0
darksoul@Ronits-MacBook-Air ~ % npx -v
10.9.0
darksoul@Ronits-MacBook-Air ~ %
我尝试了 ChatGPT 和 Gemini,但没有成功。我没有更改任何配置,并且在过去的两年里一直致力于此。但是当我昨天创建一个新应用程序时,我收到了这个错误
这是一个同伴依赖问题。
create-react-app
正在尝试安装@testing-library/[email protected]
,但它不支持React 19。您可以使用yarn
/pnpm
/bun
或降级到React 18。
npm install -g yarn
yarn create react-app <your_app_name>