1

I am using react-native and I am trying to add navigation to my project. When I add this line of code:

import { createStackNavigator } from "@react-navigation/stack";, I get this error:

Failed building JavaScript bundle.
Unable to resolve "@react-navigation/stack" from "App.js"

I tried all the solutions suggested in this stackoverflow link but, none worked for me! I reinstalled everything using these commands more than once.

I am using expo.

0

2 Answers 2

2

To use stackNavigator, you should install dependencies separately.

After install @react-navigation/native, install @react-navigation/stack:

npm install @react-navigation/stack

Tutorial says that:

To use this navigator, ensure that you have @react-navigation/native and its dependencies (follow this guide), then install @react-navigation/stack:

npm install @react-navigation/stack

Sign up to request clarification or add additional context in comments.

Comments

2

I had the same issue while using expo.

My solution was just to start expo with the flag to clear the Metro bundler cache

expo start -c

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.