react-native - 错误:未定义无法解析模块`@react-navigation/bottom-tabs`
问题描述
一直在寻找有关导航错误模块的解决方案。我试过reset-cache,删除nodu_modules,重新安装模块,但仍然无法正常工作。
错误的完整细节
Unable to resolve module `@react-navigation/native` from `src/App.js`: @react-navigation/native could not be found within the project.
包.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"
应用程序.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
推荐阅读
- angular - 如何获取设备列表并使用 ionic 4 中的 BluetoothLE 插件进行连接?
- r - 基于特定列的插补
- c#-4.0 - 使用 CF-IPCountry Geolocation 如何在 C# 中设置网站重定向
- javascript - 当活动行选中复选框时,如何将 IF 公式的 TRUE 值转换为文本?
- flask - flask-admin 保护整个管理站点,而不仅仅是索引视图
- postgresql - 如何在 FeathersJS 中为一对多关联数据库制作 GET 和 POST 请求?
- java - 如何从注释处理器的环境中排除 Maven 依赖项?
- javascript - 请求图像时不首先考虑 Iframe 中的基本元素
- php - 如何将 select sql 中的数据写入 file.sql 进行备份和导入?
- lua - conky 中的 \t 显示另一个字符