为什么会抛出与peer相关的“unable to resolve dependency tree”以及如何解决?

编程入门 行业动态 更新时间:2024-10-04 13:22:48

为什么会抛出与peer相关的“unable to resolve dependency tree”以及<a href=https://www.elefans.com/category/jswz/34/1771394.html style=如何解决?"/>

为什么会抛出与peer相关的“unable to resolve dependency tree”以及如何解决?

在我的 React Native 应用程序中,我想使用以下命令安装 React Native Firebase Auth 模块:

npm install --save @react-native-firebase/auth

但是我收到以下错误:

ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @react-native-firebase/[email protected]
npm ERR! node_modules/@react-native-firebase/app
npm ERR!   @react-native-firebase/app@"^14.11.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @react-native-firebase/app@"16.5.0" from @react-native-firebase/[email protected]
npm ERR! node_modules/@react-native-firebase/auth
npm ERR!   @react-native-firebase/auth@"*" 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.

我的 packaje.json 文件:

"react-native": "0.68.2",
"@react-native-firebase/app": "^14.11.1",
"@react-native-firebase/messaging": "^14.11.1",

提前致谢!

回答如下:

说明

如果您将

@react-native-firebase/auth
安装在
npm init -y
之后的单独文件夹中,并通过查看
node_modules
打开其文件夹,您将在其
package.json
中看到:

"peerDependencies": {
  "@react-native-firebase/app": "16.5.0"
},

这意味着它需要

16.5.0
的版本
@react-native-firebase/app
才能工作,而您在
package.json
中有版本
14.11.1
;这就是问题所在。

但问题是

@react-native-firebase/messaging
版本
14.11.1
需要
14.12.0
的版本
@react-native-firebase/app
,因为它在
package.json
中有:

 "peerDependencies": {
   "@react-native-firebase/app": "14.12.0"
 },

解决方案

解决方案是找到能让所有人都同意的版本。在您的具体情况下,一种方法是首先将它们都升级到最新版本:

npm i --save @react-native-firebase/messaging@latest @react-native-firebase/app@latest

然后,安装

@react-native-firebase/auth

npm i --save @react-native-firebase/auth

更多推荐

为什么会抛出与peer相关的“unable to resolve dependency tree”以及如何解决?

本文发布于:2024-05-30 19:15:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何解决   抛出   peer   resolve   unable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!