最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

网站源码admin35浏览0评论

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

为什么会抛出与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
发布评论

评论列表(0)

  1. 暂无评论