Search code examples
react-nativerealm

react-native link fails on realm


I have next versions of react-native / react-native-cli:

react-native-cli: 2.0.1  
react-native: 0.47.2

After installing realm with

npm install --save realm

I'm getting an error

enter image description here

Next part was solved, was left in case it will help to solve the entire problem < solved part begin

If I run

react-native link

or

react-native link realm  

I'm getting an error:

pathToProjectHere/node_modules/metro-bundler/src/lib/Terminal.js:141
    this._nextStatusStr = util.format(format, ...args);
                                              ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Module._extensions..js (module.js:416:10)
    at Object.require.extensions.(anonymous function) [as .js] (pathToProjectHerenode_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (pathToProjectHere/node_modules/react-native/local-cli/server/runServer.js:18:18)
    at Module._compile (module.js:409:26)

solved part end >

I'm still getting an error about realm constructor, even after successful link command What's wrong and is there any workaround?

I can not start the new project with realm as well - same error.

Link to issue on GitHub


Solution

  • I finally found an issue and my problem was in lack of understanding RN and Expo. As my project was created using create-react-native-app, my project initially was attached to expo. To use Realm, I had to detach.