简体   繁体   中英

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'

while trying to import 'react-native-gesture-handler' in an Expo Run React Native app.

I've tried expo install @types/hammerjs and expo install @types/hammerjs and in my application import hammer , but it still throws the error.

I'm using Hammer.JS version 2.0.8 and React Native Gesture Handler version 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.

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 ...]

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. Hence I guess this is a short term fix but is works.

My expo-cli is version 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.

I hope it helps !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM