我正在尝试在我的react-native裸项目中安装@gorhom/bottom-sheet。 我已按照那里的说明进行操作,其中包括安装
react-native-gesture-handler
和 react-native-reanimated
的说明。 安装 react-native-gesture-handler
并运行我的应用程序后,我在 iOS 模拟器 (iphone 14) 中看到此错误消息:
未找到react-native-gesture-handler模块。确保您在本机平台上运行您的应用程序并且您的代码已正确链接(cd ios && pod install && cd ..)
按照说明,我已运行
npm install react-native-gesture-handler
,并将导入放入我的根 index.js 文件中:
// index.js
import 'react-native-gesture-handler';
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => App);
我还在
pod install
文件夹中运行了 /ios
。 尽管如此,我还是看到了这个错误。 我试过了:
npx react-native link react-native-gesture-handler
,它告诉我link
是一个未知命令(不再是我的版本(0.71.8)的react-native cli的一部分)我的问题与问题错误:无法解析模块
react-native-gesture-handler
不同,如该问题所示,问题是尝试安装react-navigation
而不手动安装react-native-gesture-handler
。 问题react-native-gesture-handler module was not found中的解决方案也没有帮助,因为问题是海报已经更改了应用程序名称,并且无法再找到配置文件,并使用了react-native link
使用旧版本的react-native 来发现问题。
我在这里不知所措。看来我已经正确安装了模块,并且可以在我的 node_modules 文件夹中找到代码。 我需要
@gorham/bottomsheet
和 react-navigation
的这种依赖性。 我做错了什么?
版本:
"@gorhom/bottom-sheet": "^4.4.6",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-gesture-handler": "^2.10.2",
你解决了吗?我现在正面临这个问题