Electron App Runtime Error - Cannot find module './submit-analytics'

This seems to be a very similar issue to this: Error importing realm-js to Electron · Issue #765 · realm/realm-js · GitHub

I’m trying to get Realm to work in an Electron app with React and TypeScript, starting with electron-forge as outlined here: React with TypeScript - Electron Forge

When I insert this line after importing realm:

const realmApp = new Realm.App({ id: '***id***' });

I get the following in my webpack output:

WARNING in ./node_modules/realm/lib/utils.js
Module not found: Error: Can't resolve 'react-native' in '/***project_directory***/node_modules/realm/lib'
 @ ./node_modules/realm/lib/utils.js
 @ ./node_modules/realm/lib/index.js
 @ ./src/index.ts

ERROR in ./node_modules/realm/lib/browser/index.js
Module not found: Error: Can't resolve 'react-native' in '/***project_directory***/node_modules/realm/lib/browser'
 @ ./node_modules/realm/lib/browser/index.js 21:0-45 39:32-45
 @ ./node_modules/realm/lib/index.js
 @ ./src/index.ts

And the following runtime error when the app tries to launch:

App threw an error during load
Error: Cannot find module './submit-analytics'
Require stack:
- /***project_directory***/.webpack/main/index.js
- /***project_directory***/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
    at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at getRealmConstructor (/***project_directory***/.webpack/main/index.js:14077:29)
    at Object../node_modules/realm/lib/index.js (/***project_directory***/.webpack/main/index.js:14109:26)
    at __webpack_require__ (/***project_directory***/.webpack/main/index.js:21:30)
    at Object../src/index.ts (/***project_directory***/.webpack/main/index.js:15010:31)

I have tried setting the process.env.REALM_DISABLE_ANALYTICS = 'true'; flag, but that does not seem to help.

I would appreciate any guidance you all have.


I have the same problem :confused: