我创建了一个新的项目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
,但得到类似的错误。
7条答案
按热度按时间soat7uwm1#
这将解决问题
npm安装“--传统对等部署”@React导航/堆栈--强制
ie3xauqp2#
使用yarn而不是npm解决了我的问题。
mwngjboj3#
使用纱包管理器
使用Yarn来解决您的package.json deps
q3qa4bjr4#
相同的问题和2个建议Github-9426
1.选择是使用Yarn而不是npm。对我有效。
2.选项是react-navigation v6。但对我不起作用。v6还不稳定。
rkkpypqq5#
删除package.json文件的dependencies部分中未定义的行,然后重新安装导航对我很有效
uinbv5nw6#
npm安装@React导航/堆栈--强制
安装时,末端用力
bz4sfanl7#
尝试将导航安装在项目所在的目录中