【问题标题】:Errors in dependency tree every time I install a fresh react-app每次安装新的 react-app 时,依赖树中的错误
【发布时间】:2021-07-15 20:22:05
【问题描述】:

每次创建 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

【问题讨论】:

    标签: node.js reactjs npm


    【解决方案1】:

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

    在 GitHub create-react-app repo 中也有 a closed ticket。这是答案之一:

    嗨,

    确保

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

    您可能需要不断将依赖项更新到最新版本并等待最新版本修复此问题。

    【讨论】:

    • 另一种解决方案可能是降低 nodejs 版本。正如@jcapogna 在 GitHub 关闭票中提到的,您可以尝试使用 nodejs 版本 14 而不是最新版本来创建 react-app
    猜你喜欢
    • 2022-08-13
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 1970-01-01
    • 2022-01-19
    • 2022-10-24
    • 2015-10-14
    • 2022-11-07
    相关资源
    最近更新 更多