29

Here is the error I get:

Error

package.json

{
  "name": "LoginApp2",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "0.48.3"
  },
  "devDependencies": {
    "babel-jest": "21.2.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "21.2.1",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "jest": {
    "preset": "react-native"
  }
}

index.js

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

import UsersManager from './pages/app';
AppRegistry.registerComponent('LoginApp2', () => UsersManager);

pages/app.js

import React, { Component } from 'react';
import { AppRegistry,View,Text,StyleSheet,ScrollView,TouchableOpacity } from 'react-native';
import { StackNavigator } from 'react-navigation';

import HomeScreen from './home';
import Login from './login';
import Register from './register';
import Profile from './profile';

const UsersManager = StackNavigator({
Home: { screen: HomeScreen },
Login: { screen: Login },
Register: {screen: Register},
Profile: {screen: Profile}

});
export default UsersManager;

Can someone please help me solve this issue?

1
  • 1
    Make sure that you have installed 'react-navigation' on your project. Commented Apr 21, 2018 at 4:34

14 Answers 14

34

This error means that either you haven't installed the react-navigation module or that you have installed the module but didn't re-built your project using react-native run-android or react-native run-ios.


Following these steps should solve your issue:

  1. Install react-navigation module.
  2. Re-build your project.
  3. Restart the packager by stopping the current packager and then starting the packager again with react-native start.
Sign up to request clarification or add additional context in comments.

4 Comments

The error still occure . Nothing changed.i installed react navigation module globally and not inside the project.Rebuild the project by react-native run-android ? i did it also
You need to install the react-navigation in your project instead of globally installing it. Run npm install react-navigation --save inside your project folder.
Sorry but nothing changed same error.Even i created new project and installed react-navigation module
This error only comes if the packager doesn't get the desired module in the node modules. Just follow the steps in sequence i.e. Install react navigation in your project , then build your project using react-native run-android and restart your packager by stopping the current packager and starting again using react-native start and reload your application by pressing the reload button or by pressing double r.
16

We need to install the following dependencies:

npm i react-navigation @react-native-community/masked-view react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-screens

In code import the following:

import {createAppContainer} from 'react-navigation'; 
import {createStackNavigator} from 'react-navigation-stack';

Comments

9

Date : 25-June-2020 Working :

Follow this steps:

  1. Install React Navigation npm install react-navigation

  2. Install Dependencies expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

  3. Install React Navigation Stack npm install react-navigation-stack @react-native-community/masked-view

  4. Start the app and clear cache with npm start -c

Comments

4

You have to just install the missing module ex.

npm install react-navigation

Then restart with

npm start

Comments

4

You can use this way

  • npm install @react-navigation/native @react-navigation/native-stack

  • expo install react-native-screens react-native-safe-area-context // Expo

  • npm install react-native-screens react-native-safe-area-context // react native

import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer } from '@react-navigation/native';

const Stack = createNativeStackNavigator();

<NavigationContainer>
    <Stack.Navigator initialRouteName={ routeName } screenOptions = {{ headerShown: false }}>
        <Stack.Screen name="Home" component = { componentName } />
        <Stack.Screen name="Onboarding" component = { componentName } />
    </Stack.Navigator>
</NavigationContainer>

you can flow this document

Comments

3

I just started to learn react. And got this problem, tried everything from the internet - nothing worked. Using Yarn instead of npm helped!

1 Comment

yarn add @react-navigation/native worked for me as well
3

run "npm add @react-navigation/native" :that saved me hours

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

install has been replaced with add to add new dependencies. Run yarn add react-navigation instead.

Comments

1

This error happened after updating to the new version, to fix it, just run the following command

npx react-native start --reset-cache

Comments

1

Stop the server and run:

npm start

This will resolve the issue.

Comments

0

I resolve this error reading the react navigation documentation, execute yarn add @react-navigation/native-stack. Then the react navigation will be work

Comments

0

Install React Navigation

npm install react-navigation --legacy-peer-deps

or

yarn add react-navigation

Install Dependencies

expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

Install React Navigation Stack

npm install react-navigation-stack @react-native-community/masked-view --legacy-peer-deps

or

yarn add react-navigation-stack @react-native-community/masked-view

Start the app and clear cache with expo r -c

Comments

0

You need to install stack-navigator in your project.

  1. npm install @react-navigation/stack and
  2. npm install react-native-gesture-handler

2nd is also required, as per reactnavigation.org

You can also follow this link for detailed steps: https://reactnavigation.org/docs/stack-navigator/

Refer this image as well

Comments

0

If you're using Expo, run:

expo start -c If you're not using Expo, run:

npx react-native start --reset-cache If that doesn't work, you can also try the following:

rm -rf $TMPDIR/metro-bundler-cache-*

More information enter link description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.