我创建了一个新项目 react-native init MyProject
在 VSCode 中打开它后,我做的第一件事就是安装导航。npm install @react-navigation/native @react-navigation/stack
它抛出错误,然后我分别做了这意味着我首先做了npm install @react-navigation/native
它安装成功然后我做了npm install @react-navigation/stack
然后错误又来了:
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency
tree npm ERR! npm ERR! While resolving: MyProject@0.0.1 npm ERR!
Found: react@17.0.1 npm ERR! node_modules/react npm ERR!
react@"17.0.1" from the root project npm ERR! peer react@"*" from
@react-navigation/stack@5.14.3 npm ERR!
node_modules/@react-navigation/stack npm ERR!
@react-navigation/stack@"^5.14.2" from the root project npm ERR! npm
ERR! Could not resolve dependency: npm ERR! peer react@"^16.0" from
@react-native-community/masked-view@0.1.10 npm ERR!
node_modules/@react-native-community/masked-view npm ERR!
@react-native-community/masked-view@"^0.1.10" from the root project
npm ERR! peer @react-native-community/masked-view@">= 0.1.0" from
@react-navigation/stack@5.14.3 npm ERR!
node_modules/@react-navigation/stack npm ERR!
@react-navigation/stack@"^5.14.2" 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 /Users/chaudhrytalha/.npm/eresolve-report.txt for a full
report.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/chaudhrytalha/.npm/_logs/2021-03-17T10_09_02_128Z-debug.log
我什至尝试安装 npm install @react-native-community/masked-view
但得到类似的错误。
最佳答案
这将解决问题
npm install --legecy-peer-deps @react-navigation/stack --force
关于javascript - 安装@react-navigation/stack@5.14.3 时无法解析依赖树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66671039/