javascript - 找不到模块:安装 React Native Gesture Handler 时无法解析“@egjs/hammerjs”
问题描述
我得到错误
未找到模块:无法解析“@egjs/hammerjs”
尝试在 Expo Run React Native 应用程序中导入“react-native-gesture-handler”时。
我已经在我的应用程序中尝试过expo install @types/hammerjs
and ,但它仍然会引发错误。expo install @types/hammerjs
import hammer
我正在使用 Hammer.JS 版本2.0.8
和 React Native Gesture Handler 版本1.5.0
解决方案
我遇到了同样的问题,不得不卸载 react-native-gesture-handlernpm uninstall react-native-gesture-handler
并通过 npm 而不是 npm i react-native-gesture-handler
现在版本 1.6.1 的 expo 安装它。
这对我有用,但会触发警告消息Some of your project's dependencies are not compatible with currently installed expo package version:
- react-native-gesture-handler - expected version range: ~1.5.0 - actual version installed: ^1.6.1
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]
但是,如果您使用 expo 安装 react-native-gesture-handler,expo install react-native-gesture-handler
您会遇到同样的Module not found: Can't resolve '@egjs/hammerjs'
问题。因此,我想这是一个短期修复,但有效。
我的 expo-cli 版本是 3.15.5
这是我当前的依赖
"dependencies": {
"@react-native-community/masked-view": "0.1.5",
"expo": "^36.0.0",
"expo-av": "~8.0.0",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
"react-native-gesture-handler": "^1.6.1",
"react-native-safe-area-context": "0.6.0",
"react-native-safe-area-view": "^1.0.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-web": "^0.11.7",
"react-navigation": "^4.1.1",
"react-navigation-stack": "^2.1.1"
},
项所以你不需要安装 @types/hammerjs 作为依赖项。
我希望它有帮助!
推荐阅读
- asp.net - 回发后重新出现 ASP.NET 向导中删除的步骤
- unity3d - Unity 3D - Keycode 的多摄像机切换脚本
- javascript - 如何根据字符串值在页面上显示或隐藏 JSON 数据?
- clojure - Clojure Cond 宏的工作原理
- django - 在 Django 中使用 Oracle 进行首次迁移的问题
- javascript - 在 Angular Observables 中订阅后记录数据
- sql-server-2008-r2 - 为什么我们不能在 SQL Server 中查看已删除的表
- browser - 隐藏式字幕轨道不适用于所有浏览器
- selenium - 自定义 /etc/hosts 文件上的 docker-selenium ?
- python - 这里继承合适吗?