[英]React native: “Failed building JavaScript bundle. Unable to resolve ”@react-navigation/stack“ from ”App.js“”
I am using react-native and I am trying to add navigation to my project.我正在使用 react-native 并且我正在尝试向我的项目添加导航。 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.我尝试了此stackoverflow 链接中建议的所有解决方案,但没有一个对我有用。 I reinstalled everything using these commands more than once.
我不止一次地使用这些命令重新安装了所有东西。
I am using expo.我正在使用 expo。
To use stackNavigator, you should install dependencies separately.要使用 stackNavigator,您应该单独安装依赖项。
After install @react-navigation/native, install @react-navigation/stack:安装@react-navigation/native 后,安装@react-navigation/stack:
npm install @react-navigation/stack
To use this navigator, ensure that you have @react-navigation/native and its dependencies (follow this guide), then install @react-navigation/stack:
要使用此导航器,请确保您拥有 @react-navigation/native 及其依赖项(遵循本指南),然后安装 @react-navigation/stack:
npm install @react-navigation/stack
npm 安装@react-navigation/stack
I had the same issue while using expo.我在使用 expo 时遇到了同样的问题。
My solution was just to start expo with the flag to clear the Metro bundler cache我的解决方案是使用标志启动 expo 以清除 Metro 捆绑器缓存
expo start -c
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.