我遵循 react-native 文档的步骤。
npx react-native init SelfApp --template react-native-template-typescript
然后按照react-native-navigation的步骤操作。
yarn add @react-navigation/native
yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view
然后我添加代码
import 'react-native-gesture-handler';
到 app.tsx 的第一行。
然后运行 yarn start
,我收到此错误。
我尝试了很多次,但还是有问题,这是我的 package.json
答案 0 :(得分:0)
嘿,根据 react-native-gesture-handler 的 GitHub 上的 this discussion,这要么是链接问题(如果您使用的是 Android),要么是某些 pod 未安装(如果您使用的是 iOS)的问题。
>知道您使用的是哪个版本的 React Native 会很有帮助,因为如果 >= 60,它应该支持自动链接,如果它 < 60,您应该手动链接库。
在最后一种情况下: Try these steps
对于 iOS:
$ cd ios
$ pod install
根据我上面提到的讨论(参见 this specific response),另一种可能对其他人有效的解决方案:
1 - Delete/Remove your node_modules directory
rm -rf node_modules
2 - Install your dependencies again
如果您使用的是 Yarn $ yarn install
或者您使用的是 npm npm install
3 Clean your Gradle
cd android
./gradlew clean
cd ..
react-native run-android