RevenueCat / react-native-purchases

React Native in-app purchases and subscriptions made easy. Support for iOS and Android.
https://www.revenuecat.com
MIT License
776 stars 84 forks source link

Invariant Violation: `new NativeEventEmitter()` Expo 51 #1087

Open maamalama opened 2 months ago

maamalama commented 2 months ago

Hi! I'm getting follow error on RN Expo 51. How I can fix that?

Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes
 ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

simulator_screenshot_A301373E-F9D2-4C88-91B6-CA371F794BC1

RCGitBot commented 2 months ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

vegaro commented 2 months ago

This error is normally due to a wrong installation of the plugin. I would suggest you clean metro caches, re-install your node modules and make sure you run pod install in your iOS folder since that can sometimes be the culprit

If that doesn't help, do you mind sharing the output you see when installing the plugin, and your Podfile.lock.

Thank you

Kylescottw commented 1 month ago

I had this same issue. I tried what @vegaro said... I reset everything in my project regarding build files, include iOS folder etc. This resolved the issue temporarily but now this issue back

I am also using RN Expo 51.

Relinking the package seems to resolve the issue temporarily as well: npx expo install react-native-purchases But its strange that this happens randomly

How could it be possible that the value RNPurchases being passed into NativeEventEmitter(RNPurchases) is null? https://github.com/RevenueCat/react-native-purchases/blob/main/src/purchases.ts#L64C45-L64C56