Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i could not resolve this bundling error with react navigation v4

bundling failed: Error: Unable to resolve module react-navigation-stack from App.js: react-navigation-stack could not be found within the project.

i tried removing the node modules and reinstalling them, clearing the cache, trying the same in a new fresh project but no result

Package.json file

{
  "name": "navigator",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-reanimated": "^1.3.0",
    "react-native-screens": "1.0.0-alpha.23",
    "react-navigation": "^4.0.10"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

App.js

    import React from 'react';
    import { View, Text } from 'react-native';
    import { createAppContainer } from 'react-navigation';
    import { createStackNavigator } from 'react-navigation-stack';
    import HomeScreen from './src/screens/HomeScreen';
    import ComponentScreen from './src/screens/ComponentScreen';


    const navigator = createStackNavigator(
      {
        Home: HomeScreen
      },
      {
        initialRouteName: 'Home',
        defaultNavigationOptions: {
          title: 'App'
        }
      }
    );

    export default createAppContainer(navigator);
like image 291
John Varkey Avatar asked Dec 03 '22 18:12

John Varkey


1 Answers

Your package.json does not have the module you want to use. You need to install a module.

yarn add react-navigation-stack

or

npm install react-navigation-stack
like image 104
hong developer Avatar answered Dec 06 '22 09:12

hong developer