错误错误:需要未知模块“未定义”

Ala*_*ani 9 react-native react-navigation

当我尝试使用 @react-navigation/bottom-tabs 时,出现以下错误:

Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.
MaterialBottomTabView@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126353:43
MaterialBottomTabNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126107:32
BottomTabNavigator
EnsureSingleNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:109377:24
BaseNavigationContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:108889:28
ThemeProvider@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114532:21
NavigationContainerInner@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114392:26
App
RCTView
View
RCTView
View
AppContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:75604:36
goout(RootComponent)@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:82460:28
Run Code Online (Sandbox Code Playgroud)

包.json

Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.
MaterialBottomTabView@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126353:43
MaterialBottomTabNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:126107:32
BottomTabNavigator
EnsureSingleNavigator@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:109377:24
BaseNavigationContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:108889:28
ThemeProvider@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114532:21
NavigationContainerInner@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:114392:26
App
RCTView
View
RCTView
View
AppContainer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:75604:36
goout(RootComponent)@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.goout&modulesOnly=false&runModule=true:82460:28
Run Code Online (Sandbox Code Playgroud)

索引.tsx

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {Home} from './Pages/places/Home';
import {Details} from './Pages/places/details';

import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';

const {Navigator, Screen} = createBottomTabNavigator();

const App = () => {
  return (
    <NavigationContainer>
      <Navigator>
        <Screen name="Home" component={Home} />
        <Screen name="Details" component={Details} />
      </Navigator>
    </NavigationContainer>
  );
};

export default App;
Run Code Online (Sandbox Code Playgroud)

我已经尝试删除node_modules。我尝试使用材质底部选项卡,但出现相同的错误。

编辑1

错误 TypeError:未定义不是对象(评估 '_$$_REQUIRE(_dependencyMap[6], "@react-navigation/elements").ResourceSavingView')

此错误消息出现在第一条消息下方。

小智 9

我遇到了同样的问题,并在安装react-native-screens后修复

yarn add react-native-screens
Run Code Online (Sandbox Code Playgroud)

或者

npm install react-native-screens
Run Code Online (Sandbox Code Playgroud)


小智 0

安装react-navigation底部选项卡后,您是否重新启动捆绑包并重新运行react-native run?React Navigation 确实有一些本机代码,因此在安装模块后需要在设备上重建。

  • 是的,我这样做了,但错误仍然存​​在。 (2认同)