【发布时间】:2022-10-17 03:28:04
【问题描述】:
为了让自己熟悉 Redux 的副业,我尝试使用 create-react-app redux 模板创建一个项目,但遇到了这个错误:
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@0.1.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.3 || ^17" from react-redux@7.2.6
npm ERR! node_modules/react-redux
npm ERR! react-redux@"^7.2.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/itsme/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/itsme/.npm/_logs/2022-03-30T07_04_21_133Z-debug-0.log
`npm install --no-audit --save @reduxjs/toolkit@^1.5.1 @testing-library/jest-dom@^4.2.4 @testing-library/react@^9.3.2 @testing-library/user-event@^7.1.2 react-redux@^7.2.3` failed
我认为问题可能来自模板,所以我创建了一个 vanilla create-react-app 项目,然后尝试手动安装 react-redux,但得到了同样的错误。运行 --force 和 --legacy-peer-deps 命令没有任何效果。我的 Node (v16.14.2) 和 npm (8.5.5) 版本是最新的。谁能告诉我这里发生了什么?
【问题讨论】:
-
你能告诉我你用于
redux template的确切命令是什么吗? -
@DharmikPatel 使用的命令是
npx create-react-app my-app --template redux
标签: reactjs npm redux react-redux create-react-app