Expo CLI 无法解析模块@react-navigation/native

Expo CLI Unable to resolve module @react-navigation/native

我已经安装了所有依赖项,但我仍然在下面看到这个: 使用 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 但仍然出现此错误?

我该如何解决这个问题?

我试过上面的步骤了吗?

感谢 Kevin M. Mansour 帮助我解决了这个问题! 所以要解决这个问题! 先去你的项目删除这些东西。

.expo,node_modules,yarn.lock 个文件。

删除这些文件后安装依赖项:

纱线添加@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

输入命令后:

展览会-c

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