[英]Module not found: Can't resolve '@egjs/hammerjs' while installing React Native Gesture Handler
I get the error我收到错误
Module not found: Can't resolve '@egjs/hammerjs'
找不到模块:无法解析“@egjs/hammerjs”
while trying to import 'react-native-gesture-handler' in an Expo Run React Native app.在尝试在 Expo Run React Native 应用程序中导入“react-native-gesture-handler”时。
I've tried expo install @types/hammerjs
and expo install @types/hammerjs
and in my application import hammer
, but it still throws the error.我已经尝试过
expo install @types/hammerjs
和expo install @types/hammerjs
并在我的应用程序中import hammer
,但它仍然抛出错误。
I'm using Hammer.JS version 2.0.8
and React Native Gesture Handler version 1.5.0
我正在使用 Hammer.JS
2.0.8
版和 React Native Gesture Handler 1.5.0
版
I faced the same issue and had to uninstall react-native-gesture-handler npm uninstall react-native-gesture-handler
and install it via npm and not expo npm i react-native-gesture-handler
which is now version 1.6.1.我遇到了同样的问题,不得不卸载 react-native-gesture-handler
npm uninstall react-native-gesture-handler
并通过 npm 安装它,而不是 expo npm i react-native-gesture-handler
现在是 1.6.1 版。
This worked for me, but it triggers a warning message 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 ...]
这对我有用,但它会触发一条警告消息
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 ...]
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 ...]
However, if you install react-native-gesture-handler with expo expo install react-native-gesture-handler
you'll get the same Module not found: Can't resolve '@egjs/hammerjs'
issue.但是,如果您使用 expo
expo install react-native-gesture-handler
您将得到相同的Module not found: Can't resolve '@egjs/hammerjs'
问题。 Hence I guess this is a short term fix but is works.因此,我想这是一个短期修复,但有效。
My expo-cli is version 3.15.5我的 expo-cli 是 3.15.5 版
Here are my current dependencies "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" },
So you don't need to install @types/hammerjs as a dependency.这是我当前的依赖项
"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 作为依赖。
I hope it helps !我希望它有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.