在尝试使用命令行安装react-native-image-picker时出现错误。

huangapple go评论54阅读模式
英文:

Getting error while trying to install react-native-image-picker using command line

问题

你遇到了以下错误:

npm install react-native-image-picker

npm ERR! 代码 ERESOLVE
npm ERR! ERESOLVE 无法解决
npm ERR!
npm ERR! 在解析依赖项时发生错误:react-navigation-tabs@2.11.2
npm ERR! 找到:react-native-gesture-handler@2.9.0
npm ERR! node_modules/react-native-gesture-handler
npm ERR! 与 react-native-gesture-handler@“*” 冲突,来自 react-native-tab-view@2.16.0
npm ERR! node_modules/react-native-tab-view
npm ERR! react-native-tab-view@“^2.15.2”,来自 react-navigation-tabs@2.11.2
npm ERR! node_modules/react-navigation-tabs
npm ERR! react-navigation-tabs@“^2.11.2”,来自根项目
npm ERR! 与 react-native-gesture-handler@“>= 1.5.0” 冲突,来自 react-navigation-stack@2.10.4
npm ERR! node_modules/react-navigation-stack
npm ERR! react-navigation-stack@“^2.10.4”,来自根项目
npm ERR! 还有 1 个(根项目)
npm ERR!
npm ERR! 无法解决的依赖项:
npm ERR! 与 react-navigation-tabs@2.11.2 冲突,来自 react-native-gesture-handler@“^1.0.0”的 peer 依赖项
npm ERR! node_modules/react-navigation-tabs
npm ERR! react-navigation-tabs@“^2.11.2”,来自根项目
npm ERR!
npm ERR! 冲突的 peer 依赖项:react-native-gesture-handler@1.10.3
npm ERR! node_modules/react-native-gesture-handler
npm ERR! 与 react-navigation-tabs@2.11.2 冲突,来自根项目

我尝试更新了提到的模块,但没有任何变化。仍然遇到相同的错误。

英文:

I am getting the error below:

npm install react-native-image-picker

npm ERR! code ERESOLVE<br>
npm ERR! ERESOLVE could not resolve<br>
npm ERR!<br>
npm ERR! While resolving: react-navigation-tabs@2.11.2<br>
npm ERR! Found: react-native-gesture-handler@2.9.0<br>
npm ERR! node_modules/react-native-gesture-handler<br>
npm ERR! peer react-native-gesture-handler@"*" from react-native-tab-view@2.16.0<br>
npm ERR! node_modules/react-native-tab-view<br>
npm ERR! react-native-tab-view@"^2.15.2" from react-navigation-tabs@2.11.2<br>
npm ERR! node_modules/react-navigation-tabs<br>
npm ERR! react-navigation-tabs@"^2.11.2" from the root project<br>
npm ERR! peer react-native-gesture-handler@">= 1.5.0" from react-navigation-stack@2.10.4<br>
npm ERR! node_modules/react-navigation-stack<br>
npm ERR! react-navigation-stack@"^2.10.4" from the root project<br>
npm ERR! 1 more (the root project)<br>
npm ERR!<br>
npm ERR! Could not resolve dependency:<br>
npm ERR! peer react-native-gesture-handler@"^1.0.0" from react-navigation-tabs@2.11.2<br>
npm ERR! node_modules/react-navigation-tabs<br>
npm ERR! react-navigation-tabs@"^2.11.2" from the root project<br>
npm ERR!<br>
npm ERR! Conflicting peer dependency: react-native-gesture-handler@1.10.3<br>
npm ERR! node_modules/react-native-gesture-handler<br>
npm ERR! peer react-native-gesture-handler@"^1.0.0" from react-navigation-tabs@2.11.2<br>
npm ERR! node_modules/react-navigation-tabs<br>
npm ERR! react-navigation-tabs@"^2.11.2" from the root project
I tried updating mentioned modules but nothing happened. Still getting the same error.

答案1

得分: 1

看起来你正在使用两个不兼容的库。更确切地说,你可能在使用一个已过时的库。

问题至少存在于这两行之间:

npm ERR! Found: react-native-gesture-handler@2.9.0

npm ERR! peer react-native-gesture-handler@&quot;^1.0.0&quot; from react-navigation-tabs@2.11.2

在依赖项中有 react-native-gesture-handler@&quot;^1.0.0 表示依赖项解析应仅接受库的 1.x.x 版本,而不是 2.x.x

考虑到你现在的问题,你可能只想在你的 package.json 文件中删除对 react-native-gesture-handler 的具体引用,因为我猜你手动安装了它并且它被解析为最新版本。

然而,如果你想使你的解决方案具有未来的兼容性,你可能需要在互联网上寻找正确的库。如果你查看 react-navigation-tabs 库的官方页面 这里,你会发现这个库已不再受支持,现在你需要使用 @react-navigation/bottom-tabs
我强烈建议在深入项目之前为所有的库做好这方面的工作,因为如果做得太晚,重构可能会很麻烦,因为更新可能涉及稳定性和兼容性的改进,甚至可能是安全修复。

我希望这对你有帮助。

英文:

It looks like you are using two incompatible libraries. To be more exact, you may be using one that is outdated.

The issue at least lies between these two lines:

npm ERR! Found: react-native-gesture-handler@2.9.0

and

npm ERR! peer react-native-gesture-handler@&quot;^1.0.0&quot; from react-navigation-tabs@2.11.2

Having react-native-gesture-handler@&quot;^1.0.0 in a dependency means that the dependency resolution should only accept versions 1.x.x and not 2.x.x of the library.

Considering what your problem is right now, you may want to just remove in your package.json file the specific reference to react-native-gesture-handler, because my guess is that you installed it manually and it got resolved to the latest version.

However, if you want to make your solution future-proof, you may want to look on the internet for the right libraries. If you look on the official page of the react-navigation-tabs library here, you will find that this library is not supported anymore, you have to use @react-navigation/bottom-tabs now.
I strongly advise you do that for all your libraries before really digging into the project, because refactoring can be a huge hassle if done too late, since updates will probably involve stability and compatibility improvements, if not even security fixes.

I hope this will help.

huangapple
  • 本文由 发表于 2023年5月14日 07:10:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定