Error report when react-navigation is introduced

problem description

import {createStackNavigator, createAppContainer} from "react-navigation" when introduced, the error is reported as follows:

the environmental background in which the problem occurs

react-native: 0.57.8
react-navigation: 3.0.9

related codes

// In App.js in a new project

import React from "react";
import { View, Text } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";

class HomeScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
        <Text>Home Screen</Text>
      </View>
    );
  }
}

const AppNavigator = createStackNavigator({
  Home: {
    screen: HomeScreen
  }
});

export default createAppContainer(AppNavigator);
What is the error message that

actually sees?

error: bundling failed: Error: While trying to resolve module react-navigation from file / Users/elias/Documents/rn/rn_one/App.js , the package / Users/elias/Documents/rn/rn_one/node_modules/react-navigation/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved ( / Users/elias/Documents/rn/rn_one/node_modules/react-navigation/src/react-navigation.js . Indeed, none of these files exist:
  • / Users/elias/Documents/rn/rn_one/node_modules/react-navigation/src/react-navigation.js (.native | | .ios.js | .native.js | .js | .ios.json | .native.json | .ts | .ios.tsx | .native.ts x | .tsx)
  • / Users/elias/Documents/rn/rn_one/node_modules/react-navigation/src/react-navigation.js/index (.native | | .ios.js | .native.js | .js | .ios.json | .native.json | .json | .ios.ts | .nos.tsx | .nat ive.tsx | .tsx)
Apr.13,2022

Terminal stop, and then in npm run start

npm start

cannot be found because react-navigation is installed and cannot be restarted

Menu