调试 undefined is not an object (evaluating 'Object.keys(routeConfigs)')

Debugging undefined is not an object (evaluating 'Object.keys(routeConfigs)')

我正在使用 Expo 和 React Native 创建一个简单的 iOS 应用程序。我目前收到此错误并且不知道如何修复它。我在 Stack Overflow 上尝试了各种其他解决方案都无济于事。

我的代码是:

import 'react-native-gesture-handler';
import React from 'react';
import { createStackNavigator } from 'react-navigation-stack';
import { NavigationContainer } from '@react-navigation/native';
import HomeScreen from './src/screens/HomeScreen';

const Stack = createStackNavigator();

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

这是我的 HomeScreen.js

import React from 'react';
import { Text, View } from 'react-native';

export default function HomeScreen () {
  return (
    <View>
      <Text>Welcome Home!</Text>
    </View>
  )
}

我的包裹:

  "packages": {
    "": {
      "name": "safey",
      "version": "1.0.0",
      "dependencies": {
        "@react-native-community/masked-view": "^0.1.11",
        "@react-navigation/native": "^6.0.10",
        "@react-navigation/stack": "^6.0.10",
        "expo": "~45.0.0",
        "expo-splash-screen": "~0.15.1",
        "expo-status-bar": "~1.3.0",
        "react": "17.0.2",
        "react-dom": "17.0.2",
        "react-native": "0.68.1",
        "react-native-gesture-handler": "^2.4.2",
        "react-native-reanimated": "^2.8.0",
        "react-native-safe-area-context": "^4.2.5",
        "react-native-screens": "^3.13.1",
        "react-native-web": "0.17.7",
        "react-navigation": "^4.4.4",
        "react-navigation-stack": "^2.10.4"
      },

您可以尝试像下面这样导入堆栈导航器,看看它是否能解决问题?

import { createStackNavigator } from '@react-navigation/stack';