realm-js: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

How frequently does the bug occur?

All the time

Description

@kneth

Hello guys!

As the title above, I’m facing the error after installing realm-js:
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

This error was caused because has more than one react native version in my project. After check yarn.lock, I see that @realm/react@^0.3.1 has installed react-native@>=0.59 => This is causes error

Why @realm/react@^0.3.1 does install it?

And now, I can run my project until I remove the @realm/react package. (This means react-native@>=0.59 has been removed)

Pls, help me, How to resolve this case?

Stacktrace & log output

ERROR  TypeError: null is not an object (evaluating 'endpoint.startsWith')
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 LOG  redux-persist/stateReconciler: rehydrated keys 'app, user, _persist'
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

"realm": "^10.19.1"
"@realm/react": "^0.3.1",

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

MacOS: 12.4 (21F79) 
iPhone OS: 15.4.1

Build environment

System:
    OS: macOS 12.4
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 273.85 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.1 - ~/.nvm/versions/node/v16.14.1/bin/node
    Yarn: 1.18.0 - /usr/local/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.1/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/mac/.rvm/gems/ruby-2.7.4/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    Android SDK:
      API Levels: 23, 28, 29, 30, 31, 32
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 32.0.0
      System Images: android-27 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7935034
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.2 => 0.67.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Cocoapods version

CocoaPods: 1.11.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 33 (16 by maintainers)

Commits related to this issue

Most upvoted comments

OK! 😆 Let me know when has something new! And I hope that I will receive new info from you soon! 👍

My usual approach with “weird” React Native issues is to strip the app down to the absolute basics, to check that it works in that case – so I replaced the contents of App.tsx with just something like:

import React from 'react';
import { Text } from 'react-native';

export default () => {
  console.log('hello');

  return <Text>hello</Text>;
};

This way, none of your application code or dependencies are being imported. Then I restart the app and check that I see “hello” on the screen and/or in the logs.

Assuming that the “hello” example works, I then take a kind of “binary search” approach to finding out what is causing the app to break, by restoring the original App.tsx and commenting out nearly everything so that it just renders something simple, and then gradually uncommenting sections until I hit the error. You could also paste chunks back in to the stripped out file, but I find uncommenting to be a bit easier.

For example in your case, I first uncommented the imports, and saw that the app still loaded OK, then I uncommented the code in the component body, and saw that the app still loaded OK, then finally I uncommented the code above the component and saw this caused it to fail. I then tried commenting out different chunks of that bit of code, until I found the offending line.

I find this approach can be really useful when you’re debugging something really weird with no useful stack trace (which happens quite a lot in React Native 🤣), and can scale to finding which part of a file somewhere deep down the component hierarchy is causing issues.

Hope that helps! Are you happy for me to close your issue?