react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

Invariant Violation: `new NativeEventEmitter()` Expo 51

Open maamalama opened this issue 1 year ago • 12 comments

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

maamalama avatar Sep 15 '24 01:09 maamalama

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

RCGitBot avatar Sep 15 '24 01:09 RCGitBot

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

vegaro avatar Sep 16 '24 08:09 vegaro

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

0xkvai avatar Oct 15 '24 01:10 0xkvai

no luck here?

Mazuh avatar Apr 08 '25 01:04 Mazuh

it's still happening on expo 52.

Mazuh avatar Apr 08 '25 01:04 Mazuh

@Mazuh I just fixes it when installed pods

maamalama avatar Apr 08 '25 02:04 maamalama

@maamalama , sorry, it means you had to eject your expo app to bare workflow?

(i'm with the expo managed workflow so I currently only have some minor idea of what even a pod is 💀)

Mazuh avatar Apr 08 '25 02:04 Mazuh

i've found out that in my case I was running eas build -p ios so adding --profile development (which has "developmentClient": true, "distribution": "internal", "ios": { "simulator": true }, ... on eas.json fixed it. I think I was building non-dev assets and at the same time requiring dev assets on emulator, falling into a contradictory scenario.

Mazuh avatar Apr 08 '25 11:04 Mazuh

I am experiencing this same issue

liptonzuma avatar Apr 16 '25 17:04 liptonzuma

I was getting the same issue in react native cli then i did cd ios -> pod install but somehow the i was getting error on pod install so i did pod install --repo-update and it worked

projectninjatech avatar May 02 '25 15:05 projectninjatech

Im getting this issue over and over again. It's preventing me from using Revenuecat. I've gone through all the install tutorials, I've done npx expo install react-native-purchases, pod installed, pod install --repo-update, deleted /ios and rebuilt, man, I've tried everything. Nothing is working. Importing the purchases package yields this error:

ERROR Warning: Invariant Violation: new NativeEventEmitter() requires a non-null argument., js engine: hermes

Im on expo 53, if that matters. So frustrating

tyfiero avatar May 07 '25 04:05 tyfiero

still get this error with Expo52 ....

tun2g avatar May 20 '25 13:05 tun2g

Hey, everyone. I initially had this issue as well when I first fired up my development app after installing the package. All I had to do was rebuild the development app, and it went away.

akozy1 avatar Jul 03 '25 15:07 akozy1