question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use realm on an electron app?

See original GitHub issue
ERROR in ./~/realm/lib/browser/index.js

Module not found: Error: Can't resolve 'react-native' in
'/Users/H/Documents/MyApp/node_modules/realm/lib/browser'
 
@ ./~/realm/lib/browser/index.js 21:0-45

@ ./~/realm/lib/index.js
 
@ ./render/routes/tools/Network.js
 
@ ./render/router.js
 
@ ./render/index.js
 
@ multi (webpack)-dev-server/client?http://localhost:9527 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://localhost:9527/ webpack/hot/only-dev-server ./render/index.js

Not rewriting GET /dist/bundle.js because the path includes a dot (.) character.

I want to use realm on an electron app with Node 6, and I used the code below but it doesn’t work and the error imformation is above.

const Realm = require('realm')
let realm = new Realm({
  schema: [
    {
      name: 'LogItem',
      properties: {
        time: 'date',
        percent: 'double'
      }
    }
  ]
})
realm.write(() => {
  realm.create('Log', {
    time: new Date(),
    percent: 90.00
  })
})

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (10 by maintainers)

github_iconTop GitHub Comments

10reactions
bentron2000commented, Feb 20, 2019

@kneth Thanks again for your prompt response.

As it turns out - my attempt to use create-react-app with electron and realm was a fools errand. The build process for CRA is not compatible with the use of native node modules without ejecting and futzing around with millions of things.

For anyone else wishing to use electron/react/typescript/realm - the simplest way to get started is to use electron-forge and the react/typescript template, then add the realm npm package / import realm. Couldn’t be simpler really.

npm install -g electron-forge electron-forge init my-new-project --template=react-typescript cd my-new-project npm install realm

Hope this helps someone 😃

B

4reactions
trickyc0d3rcommented, Apr 30, 2020

What a hell? Still no solution for this?! =(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick Start with Electron — Realm
Quick Start with Electron · Overview · Setup · Set up Your Application Files · Create the Main Script File · Set up...
Read more >
Using Realm from npm on Electron JS app
The usual workaround is to use the electron-builder package and run its install-app-deps command, which will install the appropriate ...
Read more >
Installing Realm with Electron-Webpack | by Max Alexander
If you need a fast native database for your electron app then don't look any further than Realm! It's blazing fast and works...
Read more >
realm - npm
Start using realm in your project by running `npm i realm`. ... (both iOS & Android), Node.js and Electron (on Windows, MacOS and...
Read more >
Learn Electron, Mongodb and Realm
electron · realm ... First API with Node.js, Express and MongoDB. John Lindquist ... Find and Manipulate Data using Aggregation in MongoDB. Kamran...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found