错误:未定义无法解析模块`@react-navigation/bottom-tabs` [英] Error: undefined Unable to resolve module `@react-navigation/bottom-tabs`

查看:101
本文介绍了错误:未定义无法解析模块`@react-navigation/bottom-tabs`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在寻找有关导航错误模块的解决方案.我试过重置缓存,删除 nodu_modules,重新安装模块,但仍然无法正常工作.

Been searching for a solution about the error module on navigation. I've tried reset-cache, deleting nodu_modules, reinstall the module but still its not working.

错误的完整细节

Unable to resolve module `@react-navigation/native` from `src/App.js`: @react-navigation/native could not be found within the project.

Package.json

"@react-native-community/masked-view": "^0.1.9",
    "native-base": "^2.13.12",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-reanimated": "^1.8.0",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.4.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation-stack": "^2.3.11"

App.js

import * as React from 'react';
import { Text, View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

function HomeScreen() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>Home!</Text>
    </View>
  );
}

function SettingsScreen() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>Settings!</Text>
    </View>
  );
}

const Tab = createBottomTabNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator>
        <Tab.Screen name="Home" component={HomeScreen} />
        <Tab.Screen name="Settings" component={SettingsScreen} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

推荐答案

在你的 package.json 中添加 "@react-navigation/native": "^5.1.5",然后运行 ​​npm install @react-navigation/native

in your package.json add "@react-navigation/native": "^5.1.5", and then run npm install @react-navigation/native

这篇关于错误:未定义无法解析模块`@react-navigation/bottom-tabs`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆