React native 无法解析模块@react导航/物料顶部选项卡?
我尝试了许多命令来解决这个问题,但我找不到答案,什么都没用。最后,我用React native 无法解析模块@react导航/物料顶部选项卡?,react-native,react-navigation,tabbar,React Native,React Navigation,Tabbar,我尝试了许多命令来解决这个问题,但我找不到答案,什么都没用。最后,我用 npm install react-navigation-tabs react-native start --reset-cache 但是它们不起作用,我仍然会犯同样的错误。 我把它安装为 npm install @react-navigation/material-top-tabs react-native-tab-view@^2.16.0 并从“@react navigation/material top tabs”
npm install react-navigation-tabs
react-native start --reset-cache
但是它们不起作用,我仍然会犯同样的错误。
我把它安装为
npm install @react-navigation/material-top-tabs react-native-tab-view@^2.16.0
并从“@react navigation/material top tabs”导入了这个import{creatematerialopttabnavigator}代码>但仍然不行,它不起作用
这是我的package.json,因为我认为它可能有问题
{
"name": "smarthome",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-navigation/material-bottom-tabs": "^5.3.15",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.4",
"native-base": "^2.15.2",
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-paper": "^4.8.1",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.1.1",
"react-native-vector-icons": "^8.1.0",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4",
"react-navigation-tabs": "^2.11.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
}
}
这些代码解决了我的问题。您的包中似乎没有react native tab view@^2.16.0
。json
,您有“react导航选项卡”:“^2.11.1”
,我想这可能会导致问题。谢谢您的回复。我安装了它npm uninstall react native cli
npx rm-rf node_modules`npm i global react native cli
并启动了emulator,但再次出现错误。说“metro遇到文件错误SHA-1”等:/sirok先生,您知道解决方案吗,`npm install-i-g--force react native cli`解决了我的问题
npm uninstall react-native-cli
npx rm -rf node_modules
npm install -i -g --force react-native-cli