【问题标题】:React Navigation: Warning react-native-gesture-handlerReact Navigation:警告 react-native-gesture-handler
【发布时间】:2025-11-25 20:10:02
【问题描述】:

打算做什么

  1. 使用 expo 创建 react-native
  2. 添加反应导航

第一个效果不错

第二个任务有警告

第二个任务的步骤

  1. 安装 React 导航

    npm install react-navigation --legacy-peer-deps

  2. 安装依赖项

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

  3. 安装 React 导航堆栈

    npm install react-navigation-stack @react-native-community/masked-view --legacy-peer-deps

  4. 使用expo r -c启动应用并清除缓存

警告日志

编译时带有警告。 C:/Users/GBENGE AONDOAKULA/Documents/Node/food/node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/gestureComposition'中找不到导出'ComposedGestureType'(重新导出为'ComposedGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/gestureComposition'中找不到导出'ComposedGestureType'(重新导出为'ComposedGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/gestureComposition'中找不到导出'ExclusiveGestureType'(重新导出为'ExclusiveGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/flingGesture'中找不到导出'FlingGestureType'(重新导出为'FlingGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/forceTouchGesture'中找不到导出'ForceTouchGestureType'(重新导出为'ForceTouchGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/gestureStateManager'中找不到导出'GestureStateManagerType'(重新导出为'GestureStateManager')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/longPressGesture'中找不到导出'LongPressGestureType'(重新导出为'LongPressGesture')

node_modules/react-native-gesture-handler/lib/module/index.js “在'./handlers/gestures/manualGesture'中找不到导出'ManualGestureType'(重新导出为'ManualGesture')

【问题讨论】:

标签: javascript react-native react-navigation react-native-gesture-handler


【解决方案1】:

尝试将react-native-gesture-handler的版本降级为1.10.3。 它对我有用。

npm install react-native-gesture-handler@1.10.3

【讨论】:

  • 按照正确的说法运行网络不会引发错误但是我执行了上面的cmd并且我在运行时得到了这个expo start“一些依赖项与安装的 expo 包版本不兼容:- react-native-gesture-handler - 预期版本:~2.1.0 - 安装的实际版本:1.10.3 在安装正确版本的包之前,您的项目可能无法正常工作。安装这些包的正确版本,请运行:expo install [package-name ...] " @AliRehman7141 谢谢
  • 这里是使用 git bash cmd 的警告。以上是正常的窗口 cmd 而不是 PowerShell 使用项目中安装的包“expo”中的缓存 d 依赖映射 (bundledNativeModules.json) 似乎与 Expo 服务器存在暂时性问题。