反应原生导航:无法解析模块反应导航

时间:2021-07-01 09:39:07

标签: react-native

我认为这个问题是在我将我的项目推送到 github 之后出现的,我已经根据官方文档安装了,一切看起来都很好,但仍然如此。

我已经: - 重新安装 npm install @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

-删除 node_modules 然后 npm install

错误信息:

Unable to resolve module react-navigation from D:\Prog\Agora\Agora\node_modules\react-native-screens\src\createNativeStackNavigator.tsx: react-navigation could not be found within the project.

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-*
  36 |   NavigationAction,
  37 |   NavigationProp,
> 38 | } from 'react-navigation';
     |         ^
  39 | import { NativeStackNavigationOptions as NativeStackNavigationOptionsV5 } from './native-stack/types';
  40 | import { HeaderBackButton } from 'react-navigation-stack';
  41 | import {

enter image description here

1 个答案:

答案 0 :(得分:1)

您在代码中使用 React Navigation 4.x,但您使用 React Navigation 5.x 作为包,React Navigation 4.x 不适用于 5.x。您可以通过此处的官方文档升级您的代码:https://reactnavigation.org/docs/upgrading-from-4.x/

或者您可以将您的软件包更改为 4.x。