【问题标题】:How to solve this react-native error when i install drawer navigation当我安装抽屉导航时如何解决这个 react-native 错误
【发布时间】:2021-07-13 10:25:19
【问题描述】:

安装 react 导航抽屉时出现此错误。请帮忙。在安装抽屉导航器之前,我使用的是 Stack-Navigator,它工作得很好。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native-reanimated@2.2.0
npm ERR! node_modules/react-native-reanimated
npm ERR!   react-native-reanimated@"~2.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-reanimated@"^1.0.0" from react-navigation-drawer@2.7.1
npm ERR! node_modules/react-navigation-drawer
npm ERR!   react-navigation-drawer@"*" 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 C:\Users\Hp\AppData\Local\npm-cache\eresolve-report.txt for a full report.

感谢您的帮助。

【问题讨论】:

  • 这种情况何时发生?当你做 npm 安装?或者当您尝试构建应用程序时?请提供更多详细信息。
  • 尝试删除package-lock.json或者使用yarn安装
  • @Gabriel Menezes da Silva,当我尝试通过运行命令“npm install react-navigation-drawer”安装抽屉导航时发生这种情况。运行此命令后,我的 cmd 给出了上述错误。
  • @Francesco Clementi,我该如何删除 package-lock.json。
  • @Francesco Clementi,删除 package-lock.json 不起作用,因为它抛出了同样的错误

标签: react-native react-native-navigation


【解决方案1】:

错误表明它在根目录下安装了react-native-reanimated,并作为react-navigation-drawer 的依赖项。该错误似乎是对等依赖项的问题。试试这个

npm install --legacy-peer-deps

PS如果你没有使用react-native-reanimated,你可以从根目录卸载它来修复这个错误。

【讨论】:

  • 成功了!谢谢。我卸载了它,它工作。
【解决方案2】:

就像@Rohit 所说,发生错误是因为与 react-native-reanimated@2.2.0 存在一些冲突。我也尝试安装 react-navigation-tabs 并且错误也出现了。

因此,要使用此命令重试安装包:

npm install --save --legacy-peer-deps react-navigation-tabs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 2019-05-22
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多