我遇到了同样的问题,不得不卸载 react-native-gesture-handler npm uninstall react-native-gesture-handler 并 通过 npm 而不是 expo 安装它 npm i react-native-gesture-handler现在是 1.6.1 版。 p>
这对我有用,但会触发警告消息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 expo install react-native-gesture-handler 安装 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 作为依赖。
希望对你有帮助!