I have been trying to use the realm-js database on my react-native app. I am building the app with node 8.1.x. But it fails to launch due to XMLHttpRequest() being not defined. Has anyone gotten this to work? The Readme on realm-js says the node version must be <= 7.0. But I am already running realm-js 1.1.13 with node 8.1.x. So, I am not sure if this is a hard requirement or something introduced in realm-js version 2.x
@ramg Can you try node 8.9 - also what version of realm-js? You should be on a 2.3 version I believe.
I’m using realm-js version 2.2.18. I was not able to use 2.3 because of a missing import for Subscription. Also, this issue does not appear to be related to node version. I have tried node versions 6, 7, 8 & 9. When I am running the Chrome debugger, this issue goes away. Its only when I am running the app on a simulator without an active Chrome debugger.
I wonder if your issue is related to this and if the solution can be found by doing this workaround:
Not sure if this is really an issue with Realm. Because I am not able to reproduce this with a plain react-native app. It must be something specific to my app. Appreciate any debugging tips.
Turns out the issue was in detecting execution context. Our app was loading Realm before ReactNative initialized. Hence the execution container was incorrectly detected as chrome debugger, thus attempting to load XMLHttpRequest and failing. Once I moved the import of Realm to be after import of react-native, the issue was resolved.
Thanks for taking the time to share your solution. Would you be able to provide some sample code as to where you moved the import of Realm to be after the import of react-native?