realm-js: Missing Realm constructor. Did you run "react-native link realm"?

2019-10-12 18:12:48.003275+0800 mlmlApp[28520:193898] [] nw_socket_handle_socket_event [C5.1:1] Socket SO_ERROR [61: Connection refused] 2019-10-12 18:12:48.008963+0800 mlmlApp[28520:193898] [] nw_socket_handle_socket_event [C5.2:1] Socket SO_ERROR [61: Connection refused] 2019-10-12 18:12:48.017092+0800 mlmlApp[28520:193888] [] nw_connection_get_connected_socket [C5] Client called nw_connection_get_connected_socket on unconnected nw_connection 2019-10-12 18:12:48.017465+0800 mlmlApp[28520:193888] TCP Conn 0x6000020f1680 Failed : error 0:61 [61] 2019-10-12 18:12:48.222 [error][tid:com.facebook.react.JavaScript] Error: Missing Realm constructor. Did you run “react-native link realm”? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting 2019-10-12 18:12:48.226 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Error: Missing Realm constructor. Did you run “react-native link realm”? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting 2019-10-12 18:12:48.253 [error][tid:com.facebook.react.JavaScript] Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication) 2019-10-12 18:12:48.256 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Version of Realm and Tooling

  • Realm JS SDK Version: 3.2.0
  • Node or React Native: 0.61.2
  • Client OS & Version: Mac10.14.6
  • Which debugger for React Native: xCode

I have followed the documentation ‘https://realm.io/docs/javascript/latest/#missing-realm-constructor’ but it not work

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 55 (12 by maintainers)

Most upvoted comments

Android is ok

I got it working by: for both iOS AND android

having the auto-linking disabled in the config file

OSX 10.15 RN 0.61.2 REALM 3.2.0

dragged this two XCODE and deleted the test target in RealmJS.xcodeproj

Screenshot 2019-11-01 at 3 09 01 AM

added the libRealmReact.a file in link binaries with libraries

Screenshot 2019-11-01 at 3 15 32 AM

Good day guys.

image

I am having this error on an android simulator. what’s wrong?

@kneth, so let us know, the developers are waiting for their projects to be developed and so on.

you should add a migration guide for >3.4.0 I’m still trying to figure it out, but it throws error of double symbols or shows Missing Realm constructor

I believe it is related to #2460 - and we are working on it.

@rizwanatta Thank you for the recipe.

I got it working by: for both iOS AND android

having the auto-linking disabled in the config file

OSX 10.15 RN 0.61.2 REALM 3.2.0

dragged this two XCODE and deleted the test target in RealmJS.xcodeproj

Screenshot 2019-11-01 at 3 09 01 AM

added the libRealmReact.a file in link binaries with libraries

Screenshot 2019-11-01 at 3 15 32 AM

image Do it according to your documents. It’s OK. Thank you!

“react-native”: “0.61.2”, “realm”: “^3.5.0”,

If run $ react-native run-ios - its ok

If run project in xCode to simmulator - Error: Missing Realm constructor. Did you run “pod install”? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting

If remove folder ios/build and again run project in xCode - again Error “Missing Realm constructor” and folder ios/build is empty

UPD: Go to xCode menu Product -> Clean Build Folder - Yesssss YO!
Its work

@rasos We don’t yet support node v12. Try to downgrade to node v10.

I give up, I used version 2.29.1 finally I succeeded

I was able to make it work for me.

dependencies: { “react”: “16.8.6”, “react-native”: “0.60.5”, “realm”: “3.2.0”, // 3.3.0 not working }

  1. Create file react-native.config.js in root folder (I think this step is not necessary, but it prevent error messages)
module.exports = {
    dependencies: {
        'realm': {
            platforms: {
                ios: null,
            },
        },
    },
}

In xcode: 2. Add libraries: node_modules\realm\react-native\ios\RealmReact.xcodeproj node_modules\realm\src\RealmJS.xcodeproj

  1. Deal with issue with signing in target RealmJSTests. I choose the Team for Sign certificate, but I think also the option is simple delete this target.

  2. Link binary from pervious added libraries: libRealmJS.a and libRealmReact.a

Thanks this https://github.com/realm/realm-js/issues/2549#issuecomment-539239010 and this https://github.com/realm/realm-js/issues/2460#issuecomment-543905035 messages

I deleted the build directory under the android directory, ran react-native run-android and it cleared up the error.

I fixed it by cleaning the Gradle. Go into the android folder of your react-native app

// the android folder
cd android

// clean
gradlew.bat clean

// when finished
npm run android

@rizwanatta Thank you for the recipe.

Downgrading to node 10 allowed me to install realm

sudo n 10 
npm install --save realm

https://github.com/realm/realm-js/issues/2582#issuecomment-548282235

I was able to make it work for me.

dependencies: { “react”: “16.8.6”, “react-native”: “0.60.5”, “realm”: “3.2.0”, // 3.3.0 not working }

  1. Create file react-native.config.js in root folder (I think this step is not necessary, but it prevent error messages)
module.exports = {
    dependencies: {
        'realm': {
            platforms: {
                ios: null,
            },
        },
    },
}

In xcode: 2. Add libraries: node_modules\realm\react-native\ios\RealmReact.xcodeproj node_modules\realm\src\RealmJS.xcodeproj

  1. Deal with issue with signing in target RealmJSTests. I choose the Team for Sign certificate, but I think also the option is simple delete this target.
  2. Link binary from pervious added libraries: libRealmJS.a and libRealmReact.a

Thanks this #2549 (comment) and this #2460 (comment) messages

ok,thanks ,I will try later