当使用 npx create-react-app React 应用程序时,它不断抱怨“无法解决依赖关系”,尽管
npm list react
显示 [email protected] 和 npm list @testing-library/react
显示 @testing-library/[email protected]
PS D:\React> npx create-react-app austock-metamask-sdk2 --template typescript
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 C:\Users\weizh\AppData\Local\npm-cache\_logs\2024-12-16T12_59_03_556Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\Users\weizh\AppData\Local\npm-cache\_logs\2024-12-16T12_59_03_556Z-debug-0.log
PS D:\React> npm list @testing-library/react
React@ D:\React
`-- @testing-library/[email protected]
PS D:\React> npm list react
React@ D:\React
`-- @testing-library/[email protected]
+-- [email protected]
| `-- [email protected] deduped
`-- [email protected]
PS D:\React> npx -v
10.9.2
PS D:\React> npm -v
10.9.2
PS D:\React> node -v
v22.12.0
npm 配置设置legacy-peer-deps true