realm-js: Brand new realm 2.1.1 install, build fails (old lzma-native dependency)

Goals

What are you trying to achieve?

Install realm in a react native project

What did you expect to happen?

Build successful

What happened instead?

Build fails. Unmet dependencies with lzma-native.

It seems that when extracting realm-sync-cocoa it looks for a lzma-native module that doesn’t exist (binding-v3.0.4-node-v51-darwin-x64 instead of binding-v3.0.4-node-v59-darwin-x64).

Steps to Reproduce

Create a brand new react native project, install realm-js and build:

react-native init app
cd app
npm install realm --save
react-native link

Build fails.

Code Sample

Xcode build output:

v7.10.0 is already installed.
Now using node v7.10.0 (npm v4.2.0)
Resolved requirements: { SYNC_SERVER_FOLDER: 'sync',
  SYNC_ARCHIVE: 'realm-sync-cocoa-2.1.10.tar.xz',
  SYNC_ARCHIVE_ROOT: 'core' }
Target directory has a differing lockfile, overwriting.
Extracting realm-sync-cocoa-2.1.10.tar.xz => /Users/ruben/dev/test/Wayne/node_modules/realm/vendor/realm-ios
{ Error: Cannot find module '/Users/ruben/dev/test/Wayne/node_modules/lzma-native/binding-v3.0.4-node-v51-darwin-x64/lzma_native.node'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /Users/ruben/dev/test/Wayne/node_modules/lzma-native/index.js:13:14
    at Object.<anonymous> (/Users/ruben/dev/test/Wayne/node_modules/lzma-native/index.js:595:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12) code: 'MODULE_NOT_FOUND' }
Command /bin/sh failed with exit code 1

Available binding folders for lzma-native:

binding-v3.0.1-node-v58-linux-x64
binding-v3.0.1-node-v59-linux-x64
binding-v3.0.3-node-v59-linux-x64
binding-v3.0.4-node-v59-darwin-x64

Version of Realm and Tooling

  • react: 16.0.0
  • react-native 0.51.0
  • realm 2.1.1
  • lzma-native@3.0.4

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 18
  • Comments: 18 (3 by maintainers)

Most upvoted comments

As @esutton points out, a mismatch of node versions can cause many problems. We are working on getting rid of our LZMA-native dependency, but we will appreciate any help on the build side.

I solved it by NVM

  1. Please check the node version installed in error message, such as this one: ‘v7.10.0 is already installed’

  2. then run below commands nvm use v7.10.0 npm i lzma-native -D

you can see that the correct version of lzma_native.node installed

I solved with following

  1. goto https://node-pre-gyp.addaleax.net/lzma-native/ and download you version v3.0.4-node-v51-darwin-x64
  2. goto node_modules/realm/node_modules/lzma-native if folder not exist, go to node_modules/realm and run npm install, folder will be here.
  3. goto node_modules/realm/node_modules/lzma-native and extract file lzma_native-v3.0.4-node-v51-darwin-x64.tar.gz you will have a folder binding-v3.0.4-node-v51-darwin-x64
  4. now, build you project again, pass…

From my understanding, all you need is to have the matching node version at the time of realm installation. If you don’t use nvm you will have to replace your current node with the correct version, and then replace that one with the one you had in the first place (if you really have to use that one)

So if you use nvm:

  • switch to the correct node version (v7.10.0 in my case)
  • delete node_modules (so that the modules will be downloaded again)
  • npm install (with the correct version)

After this you can go back to the version you prefer. At least in my case I have done this for every realm update so far.

@vincentsong Good catch. But still I would like to get rid of the LZMA dependency 😄