software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.85k stars 954 forks source link

TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found #2847

Open lynajiang opened 1 month ago

lynajiang commented 1 month ago

Description

In process of installing @gorhom/bottom-sheet package, I was installing the gesture-handler package. I followed all the steps of installation which included adding import statements (import 'react-native-gesture-handler') to both App.tsx and index.js. In app.tsx, GestureHandlerRootView wraps the contents. The code breaks even when I comment out the @gorhom/bottom-sheet package and components.

Of course in debugging this whole debacle,

  1. Deleted the pod files, podfile.lock, and node_modules folder.
  2. Pod install and npm install in respective folders
  3. Clean build folder in xcode
  4. Deleted DerivedData
  5. Rebuild

Since this is very similar to #2749, I've tried all the solutions there. Nothing has worked.

Steps to reproduce

  1. Install @gorhom/bottom-sheet, react-native-reanimated, react-native-gesture-handler
  2. Finish installation steps for all three packages

Snack or a link to a repository

https://github.com/lynajiang/Project-Lemon-Issue-Code.git

Gesture Handler version

2.16.0

React Native version

0.73.6

Platforms

iOS

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

None

Device

Real device

Device model

iPhone 14 Pro iOS 17.4

Acknowledgements

Yes

m-bert commented 1 month ago

Hi @lynajiang! I've just build your app on both, iOS simulator and real device and everything works fine (though there was an error that useMemo was not imported). Are you sure you've properly cleaned your environment? Make sure to delete pods and node_modules

lynajiang commented 1 month ago

Yes. I am sure I properly cleaned the environment. I uninstalled and reinstalled a couple of times. If I were to comment out "import 'react-native-gesture-handler';" in both App.tsx and index.js as well as import { GestureHandlerRootView } from 'react-native-gesture-handler'; in App.tsx (and commenting out GestureHandlerRootView). I would not get any errors. This of course would make the bottomsheet component error since the Gesture Handler module is not sufficiently installed.

m-bert commented 1 month ago

In that case could you provide more information about this error? Like stack trace or full error message?

m-bert commented 1 month ago

Also, have you encountered this issue before? Did it happen after upgrading gesture handler (or react native) version?

lynajiang commented 1 month ago

The full error message is: ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","SettingsManager","DevSettings","RedBox","Networking","Appearance","DevLoadingView","UIManager","DeviceInfo"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","BugReporting","HeadlessJsTaskSupport","RNGestureHandlerModule"]}, js engine: hermes LOG Running "Lemon" with {"rootTag":1,"initialProps":{}} ERROR Invariant Violation: "Lemon" has not been registered. This can happen if:

And I have never used react-gesture-handler before. I had just installed the most up-to-date version of both react-native and react-gesture-handler packages.

lynajiang commented 1 month ago

I also have pushed a cleaner version of the code.

anucreative commented 1 month ago

I had the same trouble as you @lynajiang (new app with latest react-native : 0.73.6 and latest react-native-gesture-handler : 2.16.0. Downgrading to 2.15.0 unblocked me.

lynajiang commented 1 month ago

@anucreative Thank you! After downgrading gesture-handler to 2.15.0, it worked.

m-bert commented 1 month ago

Though downgrading may help, it is not a solution that we recommend. I will keep this issue open until we find out what causes that problem.

naitik-erpbuddies commented 4 weeks ago

I am also facing the same issue

patricktelnoni commented 2 weeks ago

I am currently facing the same issue here. Is this beacuse dependency problem during instalation, because i use react 18 on my project.. Here is the log result upon installing rect-native-gesture-handler. Please note that after i user yard, the package installed in my node_module project yet i get the ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGestureHandlerModule' could not be found.

Here is the error upon installing react-native-gesture-handler npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: AwesomeProject@0.0.1 npm ERR! Found: @types/react@18.3.0 npm ERR! node_modules/@types/react npm ERR! dev @types/react@"^18.2.6" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @types/react@"^16.9.19" from native-base@3.3.1 npm ERR! node_modules/native-base npm ERR! native-base@"3.3.1" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-debug-0.log npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: AwesomeProject@0.0.1 npm ERR! Found: @types/react@18.3.0 npm ERR! node_modules/@types/react npm ERR! dev @types/react@"^18.2.6" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @types/react@"^16.9.19" from native-base@3.3.1 npm ERR! node_modules/native-base npm ERR! native-base@"3.3.1" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/patricktelnoni/.npm/_logs/2024-04-26T16_34_16_030Z-debug-0.log