Realm with react native not working (expo

Hello,
I am trying to use Realm in my react-native application
I have installed the following package :

npm install realm
npm install @realm/react

Also followed the explanation from Using Expo and Realm React Native with expo-dev-client | MongoDB

I have clone the repository GitHub - mongodb-developer/read-it-later-maybe: Offline-First React Native Mobile App with Expo and Realm and tried to launch the android app but it always crashed.

When i execute the app in the web browser i get the following error :

NODE_OPTIONS=--openssl-legacy-provider expo start --web
WARNING: The legacy expo-cli does not support Node +17. Migrate to the versioned Expo CLI (npx expo).

This command is being executed with the global Expo CLI. Learn more.
To use the local CLI instead (recommended in SDK 46 and higher), run:
› npx expo start

Starting project at /home/cyril/Adoption/ReactRealmJSTemplateApp
Starting Metro Bundler
Starting Webpack on port 19006 in development mode.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █▀█ █▄█▀▀ ▄▀▄▀█ ▄▄▄▄▄ █
█ █   █ █▀▀▀█ ▀▀ █▀▀█▀█ █   █ █
█ █▄▄▄█ █▀ █▀▀▄█▀ █▀▄██ █▄▄▄█ █
█▄▄▄▄▄▄▄█▄▀ ▀▄█ █ █ ▀▄█▄▄▄▄▄▄▄█
█▄▄▄  █▄▄▄▄▀▄▀ ▄█▀▄▄ ▄▄▀▄▀▄█▄▀█
█▄▄▀█ █▄█▀█▄█▀▄▄ ▀█ █▄▀▀▄ ██▀██
█ ▀█▄█ ▄▀▀▄▄█▄▄▄█▀▄▄ ▄▄▀▄▀▄ █▀█
█ ▄▀▄  ▄▀ ██ ▄▄ ▄ █ ▀▄ ▄▀██▄▀██
█ █▀█ █▄▀▀▀ ▄▀▀███  ▀▄ ▀█▀▀ █▀█
█ █  ▀ ▄▀█▄██▀ ▄▄ ▄██▄▀ █▀▄▄▀██
█▄█▄▄▄█▄█▀█▀█▄█▄█▀▀█▀ ▄▄▄ ▀   █
█ ▄▄▄▄▄ █▄ █ ▄█▀ █▄█▄ █▄█ ▄▄▀██
█ █   █ █ ██▄▀▀▀▄ ▄▀█  ▄ ▄▄▄  █
█ █▄▄▄█ █  ██▀ ▄ ███▄ ▀▄▀ ▄█ ██
█▄▄▄▄▄▄▄█▄▄▄█▄█▄█▄▄███████▄▄███

› Metro waiting on exp://192.168.1.139:19000
› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

› Webpack waiting on http://192.168.1.139:19006
› Expo Webpack (web) is in beta, and subject to breaking changes!

› Press a │ open Android
› Press w │ open web

› Press r │ reload app
› Press m │ toggle menu

› Press ? │ show all commands

Logs for your project will appear below. Press Ctrl+C to exit.
[object Object]
[object Object]
[object Object]
WARNING in ./node_modules/@realm/react/dist/AppProvider.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/AppProvider.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/AppProvider.tsx'

WARNING in ./node_modules/@realm/react/dist/RealmProvider.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/RealmProvider.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/RealmProvider.tsx'

WARNING in ./node_modules/@realm/react/dist/UserProvider.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/UserProvider.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/UserProvider.tsx'

WARNING in ./node_modules/@realm/react/dist/cachedCollection.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/cachedCollection.ts' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/cachedCollection.ts'

WARNING in ./node_modules/@realm/react/dist/cachedObject.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/cachedObject.ts' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/cachedObject.ts'

WARNING in ./node_modules/@realm/react/dist/index.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/index.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/index.tsx'

WARNING in ./node_modules/@realm/react/dist/useObject.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useObject.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useObject.tsx'

WARNING in ./node_modules/@realm/react/dist/useQuery.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useQuery.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useQuery.tsx'

WARNING in ./node_modules/@realm/react/dist/useRealm.js
Module Warning (from ../../.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useRealm.tsx' file: Error: ENOENT: no such file or directory, open '/home/cyril/Adoption/ReactRealmJSTemplateApp/node_modules/@realm/react/src/useRealm.tsx'

ERROR in ./node_modules/bindings/bindings.js:5
Module not found: Can't resolve 'fs'
  3 |  */
  4 | 
> 5 | var fs = require('fs'),
  6 |   path = require('path'),
  7 |   fileURLToPath = require('file-uri-to-path'),
  8 |   join = path.join,

ERROR in ./node_modules/bindings/bindings.js:6
Module not found: Can't resolve 'path'
  4 | 
  5 | var fs = require('fs'),
> 6 |   path = require('path'),
  7 |   fileURLToPath = require('file-uri-to-path'),
  8 |   join = path.join,
  9 |   dirname = path.dirname,

ERROR in ./node_modules/file-uri-to-path/index.js:6
Module not found: Can't resolve 'path'
  4 |  */
  5 | 
> 6 | var sep = require('path').sep || '/';
  7 | 
  8 | /**
  9 |  * Module exports.

web compiled with 3 errors and 9 warnings
Started Metro Bundler

What can i do to fix this issue and make realm compatible with react-native and expo ?
Is it a version issue?(the documentation asks for Node 12 or higher)
If the version is the issue, which version should i use?

Additional information about my versions:
  Node : v18.12.1
  expo-cli : 6.3.0
   “@realm/react”: “^0.4.3”,
   “expo”: “~47.0.12”,
   “expo-dev-client”: “~2.0.1”,
   “metro-core”: “^0.75.0”,
   “react”: “18.1.0”,
   “react-native”: “0.70.5”,
   “realm”: “^11.4.0”,

1 Like

Hi there, u need dowgrade your NODE Version to 16.x
this problem happened cause the module incompatible ssl version.
also u can try this, hard mode to solve
install the Expo CLI global

set all JAVA_HOME and ANDROID_HOME
variables enviroments and install lasted JDK path too, then set
%ANDROID_HOME%\emulator
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
%ANDROID_HOME%\platform-tools
I was solved my problem now I have Node -v = 19
and JDK  = OpenJDK 11.0.18+10 (build 11.0.18+10, mixed mode)```

Hello,

thank you for your answer, I have also created a ticket in the github repository for realm
and they gave me a solution :

realm@11.4.0 is only compatible with expo@48 and react-native@0.71 . You will have to either downgrade realm or upgrade expo . Here is our compatibility chart.

Best regards

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.