每次安装新的 react-app 时,依赖关系树都会出错

时间:2021-07-10 18:37:36

标签: node.js reactjs npm

有一段时间我每次创建 React 应用时都会出错。

我尝试删除所有 node/npm 版本,并使用最新的 node LTS 重新安装一个干净的版本,但是,我仍然收到以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: type-fest@0.21.3
npm ERR! node_modules/type-fest
npm ERR!   type-fest@"^0.21.3" from ansi-escapes@4.3.2
npm ERR!   node_modules/ansi-escapes
npm ERR!     ansi-escapes@"^4.2.1" from @jest/core@26.6.3
npm ERR!     node_modules/@jest/core
npm ERR!       @jest/core@"^26.6.0" from jest@26.6.0
npm ERR!       node_modules/jest
npm ERR!         peer jest@"^26.0.0" from jest-watch-typeahead@0.6.1
npm ERR!         node_modules/jest-watch-typeahead
npm ERR!         1 more (react-scripts)
npm ERR!       1 more (jest-cli)
npm ERR!     ansi-escapes@"^4.3.1" from jest-watch-typeahead@0.6.1
npm ERR!     node_modules/jest-watch-typeahead
npm ERR!       jest-watch-typeahead@"0.6.1" from react-scripts@4.0.3
npm ERR!       node_modules/react-scripts
npm ERR!         react-scripts@"^4.0.3" from the root project
npm ERR!     2 more (jest-watcher, terminal-link)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional type-fest@"^0.13.1" from @pmmmwh/react-refresh-webpack-plugin@0.4.3
npm ERR! node_modules/@pmmmwh/react-refresh-webpack-plugin
npm ERR!   @pmmmwh/react-refresh-webpack-plugin@"0.4.3" from react-scripts@4.0.3
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"^4.0.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/johnnys/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/johnnys/.npm/_logs/2021-07-10T18_33_36_275Z-debug.log

1 个答案:

答案 0 :(得分:0)

您从有关此问题的类似帖子中收到了相同类型的错误 npm audit fix --force never able to avoid vulnerabilities

GitHub create-react-app 存储库中也有 a closed ticket。这是答案之一:

<块引用>

嗨,

确保

您的依赖项(包括 NodeJS/npm/npx/yarn)是最新的 确保没有全局安装 CRA 关注 https://create-react-app.dev/docs/getting-started/ 指南获取 开始

您可能需要不断将依赖项更新到最新版本,然后等到最新版本解决此问题。