【问题标题】:npm ERR! Conflicting peer dependency: react@18.0.0错误!冲突的对等依赖:react@18.0.0
【发布时间】:2023-01-30 13:21:47
【问题描述】:

我似乎无法理解为什么会发生此错误。我正在尝试使用另一个已经创建的新 react-native 项目创建一个新的 react-native 项目,该项目位于目录树中不低于其他安装的不同目录中。我已经卸载并重新安装了我认为可能是问题的节点。我使用了 brew doctor 并删除了我之前安装的自制软件 usr/local/includes

我正在尝试全新安装 React-native,但看来我做不到。

感谢您的任何帮助。

这是我不断收到的错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native@0.67.4
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from @react-native-community/cli@6.4.0
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.0" from react-native@0.67.4
npm ERR!   react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.0.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.0.0" from react-native@0.69.1
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.69.1" 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/Name/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Name/.npm/_logs/2022-07-14T06_15_09_791Z-debug-0.log

【问题讨论】:

    标签: node.js react-native npm


    【解决方案1】:

    我和你有同样的问题。修复错误。

    打开 cli 然后键入:open /Users/Name/.npm 然后删除文件夹 _cacache、_logs、_npx。

    删除这些文件夹后,我可以安装新的 React Native 项目。

    【讨论】:

    • 感谢您的建议,我已经擦除硬盘驱动器以修复它并进行全新安装,现在我没有任何问题。那可能有用,所以无论如何感谢您的回复。
    • Windows用户呢?
    【解决方案2】:

    在命令末尾添加 --legacy-peer-deps

    --legacy-peer-deps
    

    【讨论】:

      【解决方案3】:

      第一步:打开/Users/Name/.npm

      第 2 步:要在 Mac 上查看隐藏文件夹,请按Cmd + Shift + .(dot)

      第 3 步:删除文件夹 _cacache、_logs、_npx

      【讨论】:

        【解决方案4】:

        对于 Windows 用户:

        打开C:Users%username%AppDataLocal pm-cache然后删除文件夹_cacache _logs_npx

        删除这些文件夹后,我可以在我的 Windows PC 上安装一个新的 React Native 项目。

        【讨论】:

          猜你喜欢
          • 2023-01-03
          • 1970-01-01
          • 2021-07-15
          • 2021-02-26
          • 1970-01-01
          • 1970-01-01
          • 2022-08-12
          • 2021-07-19
          • 2016-08-21
          相关资源
          最近更新 更多