Trouble getting Realm Version 5.0.0 to Work in React-Native? Here’s The Solution…

This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io

Welcome back dear internet friend!

So it looks like you’re having trouble getting Realm Version 5.0.0 in your React-Native app? It’s not your fault! For the past several hours I’ve found myself banging my head against the wall with the same problem, and here’s what I’ve discovered: Realm has not updated their JavaScript documentation to match version 5.

That’s right, while the documentation may “say” that it’s for version 5, as of April 2020 the code samples are all for version 4 and likely will not work if you’ve gone ahead and installed version 5. The fix for this is simple however. Just go ahead and uninstall version 5, and then install version 4 and all shall be well!

$ npm uninstall --save realm

$ npm install --save realm@4.0.0-beta.0

$ cd ios

$ pod install

$ cd ../

Then try running you’re app again…

$ npx react-native run-android

Furthermore, I think the reason behind this mistake by the Realm team is that they are primarily focused on iOS first, and Android second, and React-Native/NodeJS last! So if you are doing native iOS development you probably should be using version 5 if you’re starting a new project. But if you’re a React-Native or Node developer, you definitely want to be using version 4 until they updated their docs.

 

topherPedersen