首页 > 解决方案 > 如何解决 react-native-spotify-remote 的这个 NPM 依赖问题

问题描述

我无法弄清楚如何解决我遇到的依赖相关问题。我正在尝试react-native-spotify-remote在新的 React Native 项目中安装 npm 模块,但出现以下错误:

$ npx react-native init test && cd test
$ npm i --save react-native-spotify-remote
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: test@0.0.1
npm ERR! Found: react-native@0.63.3
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.63.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.61.5" from react-native-spotify-remote@0.3.2
npm ERR! node_modules/react-native-spotify-remote
npm ERR!   react-native-spotify-remote@"*" 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\xxx\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxx\AppData\Local\npm-cache\_logs\2020-11-15T13_40_38_674Z-debug.log

当我阅读此错误时,在我看来,它react-native-spotify-remote的依赖项react-native为 0.61.5 或更高版本,并且安装了 0.63.3 版本。这不意味着依赖得到满足吗?我知道通过将 react-native 降级到早期版本,如他们的示例应用程序中所使用的那样,我可能可以解决这个问题,但我想先尝试了解为什么这不起作用,理想情况下我想使用最新版本.

使用--forceor--legacy-peer-deps标志也不能解决问题。

我还在 GitHub 存储库上打开了一个问题,但到目前为止也没有运气。

标签: node.jsreact-nativenpmnpm-install

解决方案


看起来这是 npm 的 Peer Dependencies 的问题,请尝试:

npm install --legacy-peer-deps

推荐阅读