Realm-js: Missing dependencies

Created on 27 Feb 2019  ·  21Comments  ·  Source: realm/realm-js

Goals

Try to run and build the new version 2.24.0.

Expected Results

The build process should download the new coca and decompress and unzip it.

Actual Results and Workaround

The packages "decompress" and "https-proxy-agent" are missing.

Error: Cannot find module 'https-proxy-agent'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/ProjectPath/node_modules/realm/scripts/download-realm.js:25:25)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Command PhaseScriptExecution failed with a nonzero exit code

It works if you do

yarn add decompress
yarn add https-proxy-agent

Steps to Reproduce

Try to install the new version.

Version of Realm and Tooling

  • Realm JS SDK Version: 2.24.0
    React Native Environment Info:
    System:
    OS: macOS 10.14.3
    CPU: (4) x64 Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
    Memory: 31.00 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
    Binaries:
    Node: 10.11.0 - /usr/local/bin/node
    Yarn: 1.3.2 - ~/.yarn/bin/yarn
    npm: 6.8.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
    iOS SDK:
    Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
    API Levels: 22, 23, 25
    Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.1, 25.0.2
    System Images: android-22 | Google APIs Intel x86 Atom, android-23 | ARM EABI v7a
    IDEs:
    Android Studio: 3.0 AI-171.4443003
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
    react: 16.6.3 => 16.6.3
    react-native: 0.58.5 => 0.58.5
    npmGlobalPackages:
    create-react-native-app: 1.0.0
    react-native-camera: 0.8.0
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
O-Community P-1-Required T-Help

All 21 comments

Also these should be dependencies not devDependencies: (required in scripts/download-realm.js)

  • fs-extra
  • https-proxy-agent
  • ini
  • decompress
  • progress
  • stream-counter

@arnebr @shenjunru I haven't been able to reproduce it from a fresh project (see the attached screenshot):

react-native init Test
cd Test
yarn add realm
react-native link realm
react-native run-ios

screenshot 2019-02-28 at 14 37 02

Moreover, first building a project with v2.23.0 and then upgrade to v2.24.0 also works fine.

When looking at node_modules/realm/node_modules, I see both decompress and http-proxy-agent.

Btw, I am using node v10.13.0 and yarn v1.13.0.

Indeed in a clean space it works fine, don´t know what happend here then. Sry for bothering.

@kneth, @arnebr Could you try yarn add [email protected]
NPM and Yarn do not install "devDependencies" of "dependencies"

@shenjunru As I outlined, I did try with yarn.

@kneth

Could you check listed packages exist in the project node_modules, not out of project.
Here, It is not work for [email protected] and [email protected] with [email protected] and fresh react-native project.
Thanks.

  • decompress
  • fs-extra
  • https-proxy-agent
  • ini
  • progress

@kneth + @shenjunru

I'm having the same issue w/ npm 6.7.0, upgrading from [email protected] in an existing project.

I too got the error:

~/react-native/duacollection (master ✘)✖✹✭ ᐅ npm install -save [email protected]

> [email protected] install /Users/anam.hossain/react-native/duacollection/node_modules/realm
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://static.realm.io/node-pre-gyp/2.24.0/realm-v2.24.0-node-v67-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
  TOUCH Release/obj.target/OpenSSL.stamp
  ACTION binding_gyp_vendored_realm_target_download_realm /Users/anam.hossain/react-native/duacollection/node_modules/realm/vendor/realm-mac-x64
internal/modules/cjs/loader.js:615
    throw err;
    ^

Error: Cannot find module 'https-proxy-agent'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/anam.hossain/react-native/duacollection/node_modules/realm/scripts/download-realm.js:25:25)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
make: *** [/Users/anam.hossain/react-native/duacollection/node_modules/realm/vendor/realm-mac-x64] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.10.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/a
am.hossain/react-native/duacollection/node_modules/realm/compiled/node-v67_darwin_x64/realm.node" "--module_name=realm" "--module_path=/Users/anam.hossain/react-native/duacollecti
n/node_modules/realm/compiled/node-v67_darwin_x64" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
gyp ERR! cwd /Users/anam.hossain/react-native/duacollection/node_modules/realm
gyp ERR! node -v v11.10.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/11.10.1/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to
build --module=/Users/anam.hossain/react-native/duacollection/node_modules/realm/compiled/node-v67_darwin_x64/realm.node --module_name=realm --module_path=/Users/anam.hossain/reac
-native/duacollection/node_modules/realm/compiled/node-v67_darwin_x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/anam.hossain/react-native/duacollection/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:984:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/11.10.1/bin/node" "/Users/anam.hossain/react-native/duacollection/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/anam.hossain/react-native/duacollection/node_modules/realm
node-pre-gyp ERR! node -v v11.10.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/11.10.1/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/anam.hos
ain/react-native/duacollection/node_modules/realm/compiled/node-v67_darwin_x64/realm.node --module_name=realm --module_path=/Users/anam.hossain/react-native/duacollection/node_mod
les/realm/compiled/node-v67_darwin_x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v67' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/anam.hossain/.npm/_logs/2019-03-05T06_45_55_411Z-debug.log

@anam-hossain:

Pre-built binaries not found for [email protected] and [email protected]

We currently don't support node.js v11. Please try again using node.js v10 or v8.

@HolySamosa Upgrading to v2.24.0 brings many new things so you might have to clean your workspace. Did you clean your workspace before building?

Found issue.

In v2.24.0, The Xcode project will run [ ! -d node_modules/fs-extra ] && npm install --no-save
Which install those modules locally inside node_modules/realm.
Also install node via nvm (same as previous versions).

I think those are not good behaviors.

  1. Those modules are "real" dependencies for the project use realm-js.
  2. The script does not check exist node.
  3. Usually, the project with realm-js should has node support already.

I also wrote a shell script download-realm.sh to replace download-realm.js
It provides same behavior as download-realm.js.
https://gist.github.com/shenjunru/2328b60558c769fe4975378c8eaacc7d

@shenjunru I have tried with the exact same versions as you, and the modules are installed.
screenshot 2019-03-05 at 15 42 28

I can confirm that I get this on version 2.24.0 but I don't get this when I change my package.json to version 2.23.0.

@shenjunru It's a good shell script. The reason we wrote it in JS originally was that we also need it on Windows.

The shell script within Xcode is using a particular version of node. The issue here is that if you have multiple versions of node installed, Xcode will pick the default version. Xcode is spawning a new login shell, and therefore it doesn't inherit the settings from any shell.

I'm happy to report that I'm no longer seeing this issue w/ v2.25.0. :-)
@kneth @shenjunru

I don't have this bug on my machine, but one of my workmate had this issue when compiling our project with realm-js 2.25.0.

He had to add these modules to our package.json.

"command-line-args": "^5.1.1",
"decompress": "^4.2.0",

@StevenMasini We moved those dependencies in v2.26.0 so if you upgrade, it should have been solved.

I added a issue related to this

https://github.com/realm/realm-js/issues/2474

hey guys, you just need to react-native run-ios after react-native link realm and then to Build on Xcode

aza_aaAAAAASS_**

ASADAAAA

Was this page helpful?
0 / 5 - 0 ratings