Reputation: 286
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.
Upvotes: 1
Views: 2705
Reputation: 127
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
Upvotes: 2
Reputation: 8459
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
Upvotes: 2