React Native 无法解析请求“/node/node/node/node”,

egdjgwm8  于 2023-06-30  发布在  React
关注(0)|答案(1)|浏览(123)

我已经安装了所有的依赖,但我仍然得到下面的:使用Expo-CLI?

Failed building JavaScript bundle.


Unable to resolve module @react-navigation/native from /home/jonteyh/React_Native/projects/MealsToGo/App.js: @react-navigation/native could not be found within the project or in these directories:

  ../../../node_modules/@react-navigation


If you are sure the module exists, try these steps:

 1. Clear watchman watches: watchman watch-del-all

 2. Delete node_modules and run yarn install

 3. Reset Metro's cache: yarn start --reset-cache

 4. Remove the cache: rm -rf /tmp/metro-*

  3 | import { ThemeProvider } from "styled-components/native";

  4 | import { theme } from "./src/infrastructure/theme";

> 5 | import { NavigationContainer } from "@react-navigation/native";

    |                                      ^

  6 | //import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";

  7 |

  8 | import {

› Stopped server

我已经尝试删除.expo,node_modules,但仍然得到这个错误?
我该如何解决这个问题?
我试过上面的步骤了吗?

olhwl3o2

olhwl3o21#

感谢Kevin M. Mansour帮助我解决这个问题!
首先,转到您的项目并删除.exponode_modulesyarn.lock
删除这些文件后,安装依赖项:

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

然后运行以下命令:

expo r -c

之后,所有的错误都消失了!如果你的项目不是太大,请删除yarn.lock文件,如果你有一个大项目,它可能会引入一些错误!所以要小心删除yarn.lock文件。

相关问题