Closed secretyouth closed 7 years ago
Were you able to figure this out? Seems like we have an incompatibility with the tests or other frameworks you are using. If you can provide a sample project which reproduces the issue we may be able to figure this out more easily.
@alazier I ended up removing realm.io at this stage until someone was able to solve this issue. It was still happening when running Mocha Tests.
I was unable to find any information on how to resolve it.
It's a private project at this stage, so I am unable to provide the source for it. It was a very basic project (at the time of posting) and contains only realm, react native and mocha (enzyme, chai, mockery).
Im sure if you set up a basic react-native project with the above package.json you should be able to encounter the same issue.
You have to use the NodeJS backend for building tests that will be run in a node context (which is Mocha, usually)
try executing the scripts/download-core.sh node
script, then ./src/node/build-node.sh
from withinnode_modules/realm
I"m having the same problem with AVA and Realm for React Native.
OSX 10.11, Node 6.2.2
I tried the download-core.sh & build-node.sh fix, rnpm link, no dice. I also tried upgrading node-gyp as well.
/Users/DOBLETBOOF/react-native/dev/ReduxTest/node_modules/bindings/bindings.js:91 throw err ^
→ /Users/DOBLETBOOF/react-native/dev/ReduxTest/node_modules/realm/compiled/6.2.2/darwin/x64/realm.node
at bindings (/Users/DOBLETBOOF/react-native/dev/ReduxTest/node_modules/bindings/bindings.js:88:9)
at Object.
5 passed 1 exception
package.json:
{ "name": "ReduxTest", "version": "0.0.1", "private": true, "scripts": { "start": "node nodemodules/react-native/local-cli/cli.js start", "remotedev": "remotedev --hostname=localhost --port=8000", "test": "ava" }, "dependencies": { "react": "15.2.1", "react-native": "0.29.0", "react-native-router-flux": "^3.31.0", "react-redux": "^4.4.5", "realm": "^0.14.1", "redux": "^3.5.2", "redux-batched-actions": "^0.1.2", "redux-thunk": "^2.1.0", "underscore": "^1.8.3" }, "devDependencies": { "ava": "^0.15.2", "babel-eslint": "^6.1.2", "babel-preset-react-native": "^1.9.0", "deep-freeze-node": "^1.1.2", "enzyme": "^2.4.1", "eslint": "^3.0.1", "eslint-plugin-react": "^5.2.2", "eslint-plugin-react-native": "^1.1.0", "mockery": "^1.7.0", "nyc": "^7.0.0", "react-dom": "^15.2.1", "react-native-mock": "^0.2.4", "remote-redux-devtools": "^0.3.3", "remotedev-server": "^0.1.2" }, "ava": { "babel": "inherit", "files": [ "Tests/*/_.js", "!Tests/Setup.js" ], "require": [ "babel-register", "babel-polyfill", "react-native-mock/mock", "./Tests/Setup" ] } }
Any thoughts? I won't be able to move forward with Realm if I can't get AVA or Jest to work with it.
@TGPSKI we are looking into it to better understand what the issue is.
Hey, I got realm to work under both mocha and AVA, based on @bppr's comment. In your project folder:
cd node_modules/realm
./scripts/download-core.sh node
src/node/binding.gyp
and on line 37 replace ../../node_modules/nan
with <!(node -e 'require(\"nan\")')
./src/node/build-node.sh
I only needed step 3 because I've got npm3 and it installs the nan
module in a location realm's binding.gyp
file doesn't expect.
@fealebenpae changed the above and still getting the following. Maybe I am missing something basic here?
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] CXX(target) Release/obj.target/realm/node_init.o In file included from ../node_init.cpp:19: In file included from ../node_init.hpp:21: In file included from ../node_string.hpp:21: In file included from ../node_types.hpp:28: ../../js_types.hpp:25:10: fatal error: 'realm/util/to_string.hpp' file not found
^
1 error generated. make: *\ [Release/obj.target/realm/node_init.o] Error 1
@TGPSKI after you execute step 2, is there a core-node
folder under node_modules/realm
and does it have meaningful contents?
@fealebenpae hmm, no. i have core and core-1.1.2 folders but I don't see this tree like you have above.
edit: ./scripts/download-core.sh node vs ./scripts/download-core.sh
@TGPSKI that's just me running tree
on the folder to dump its contents. Does yours look anything like that?
Also, it should be core-node
and core-node-1.1.2
. Did you pass the node
argument to download-core.sh
?
yes yes yes got it! Just ran some AVA tests with a Realm import, first successful test!
More to come.
Much thanks to @fealebenpae!!
This is super awesome as I already wrote out my Realm helpers and didn't want to revert all that.
Only one basic test so far, but this is really promising!
Glad you got things working!
thanks for this! helped a lot :) I've done a bash version that I used on CircleCI, I put it here just in case:
./bin/build-realm.sh
#!/usr/bin/env bash
set -e
npm install -g node-gyp@3.4.0
cd ./node_modules/realm
# only build realm if not already builded
if [ -d "./node_modules/.bin" ]; then
echo 'Realm already builded'
else
mkdir -p ./node_modules/.bin
./scripts/download-core.sh node
sed -i -e "s#../../node_modules/nan#<\!\(node -e 'require\(\\\\\"nan\\\\\"\)'\)#g" src/node/binding.gyp
./src/node/build-node.sh
fi
and my circle.yml
:
machine:
node:
version: 6.0.0
dependencies:
cache_directories:
- ~/nvm/versions/node/v6.0.0/lib/node_modules/node-gyp
- ~/nvm/versions/node/v6.0.0/bin/node-gyp
post:
- ./bin/build-realm.sh
All, even though this was resolved, I wanted to post that we are not officially supporting realm-js
with Node, although we intend to soon. Instead, if you are interested, please email me at af@realm.io as I would like to learn more on what you would like to see in an official Node release.
hi, I'm on step 4, ./src/node/build-node.sh, and I received this error:
gyp info using node-gyp@3.4.0 gyp info using node@6.3.1 | darwin | x64 gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] CXX(target) Release/obj.target/realm/node_init.o c++: error: unrecognized command line option '-stdlib=libc++' make: *\ [Release/obj.target/realm/node_init.o] Error 1
I think this is using gcc and not clang, in which case my gcc is:
$ gcc --version gcc (MacPorts gcc5 5.4.0_0) 5.4.0
@shkyang: node-gyp is hardcoded to expect Xcode/clang on mac. I think you need to temporarily remove MacPorts from PATH
In order to get it to build.
@fealebenpae: I'm not an expert at the node compilation system, but it seems like the issue here is that clang is not being hardcoded, I was able to get around it like this:
cd ./src/node/build CXX=clang make
Then I did the last two steps of build.sh manually.
cd ../.. mkdir -p build ln -fs "../src/node/build/$CONFIGURATION/realm.node" build/
I wonder if it makes sense to hardcode CXX to clang (on osx) in the .mk file
@shkyang: node-gyp literally expects that CC
and CXX
will understand the same arguments clang
would. Realm's gyp files do not select for a compiler anywhere. I believe exporting the CXX
variable to clang++
like you have done is a good solution.
@fealebenpae. I see what you mean, In this case we can make step 4
CXX=clang ./src/node/build-node.sh
Could also alter build-node.sh to explicitly set CXX on OSX, but I think we've beat on the issue enough.
Now the tests pass for me, but they don't quit - Jest prints out summary and hangs.
FYI for me the steps to success were as follows
step 1 cd node_modules/realm
step 2 ./scripts/download-core.sh node
Previous step 3 (Open src/node/binding.gyp and on line 37 replace ../../node_modules/nan with <!(node -e 'require(\"nan\")')
) wasn't required for me as the correct value was already there
step 3 npm install
step 4 ./src/node/build-node.sh
@sharq1: do you by any chance build from the latest source in the repo, instead of using the package from npm? Also, what's your package.json
like, especially the jest
section? And what version of jest do you use?
Sorry, forgot to mention that I'm using realm from git:
"realm": "git+https://git@github.com/realm/realm-js.git",
"jest": "15.1.1",
"jest-cli": "15.1.1",
"jest-react-native": "15.0.0",
"jest": {
"preset": "jest-react-native",
"moduleNameMapper": {
"\\./datepicker$": "<rootDir>/node_modules/tcomb-form-native/lib/templates/bootstrap/datepicker.ios.js"
},
"preprocessorIgnorePatterns": [
"node_modules/(?!react-native|tcomb-form-native|apsl-react-native-button)"
],
"testRegex": "(/__tests__/.*|\\.(test))\\.js$",
"collectCoverage": true,
"verbose": true
},
When I was using 0.14.3 from npm I was getting Missing Realm constructor - please ensure RealmReact framework is included!
error instead of bindings error.
@sharq1: I just tried a new project with your setup with a single test that imports Realm and I can't get jest to hang. Could you prepare a simple app that demonstrates the issue and put it up somewhere so that we can try and debug it?
I was able to narrow down the problem - having just the Realm initialized (new Realm({})
) causes the terminal to hang. No actual db actions influence this.
Hello, The fix you proposed works but when the test uses Realm Jest never stop the process.
@sharq1 The unique problem that I found with your approach is that I cant compile the applications because there is no android folder... I tried to build it but it was not found :( (they ignore it on https://github.com/realm/realm-js/blob/master/react-native/.npmignore#L1)
@sharq1 @alexsotocx and for everyone else that stumbled upon this issue, fixes it and then experiences a "hanging terminal": I eventually realized that I didn't close
my Realm instances (easy to overlook as it's not shown in the Realm React Native docs).
I solved it by running this at the end of the test suite:
afterAll(() => { realm.close(); });
@johannesschirrmeister the sad thing is that I can't use on my linux machine for CI. We have to wait.
@sharq1 I was using your script for a while on v0.14.3 tag was working... but the new version doesn't have ./src/node/build-node.sh. Do you know what this step is replaced with now?
Cheers
@andrewvmail you should no longer need to build node as node support has been included into the npm module directly.
Hi all,
Hopefully someone can chime in and help me figure this out. I am using React-Native (0.28.0) & Realm (0.14.1) since installing ream my react native tests have been failing due to the following error.
I've literally hit a wall, when I remove the react components that are requiring Realm, they test fine. But with realm the error bellow is returned.
Any help or ideas are much appreciated, as I have tried remove node_modules, npm rebuild & downgraded realm.
Package.json { "name": "reactApp", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "mocha --require react-native-mock/mock.js --compilers js:babel-core/register --recursive test/*.js" }, "dependencies": { "lodash": "^4.13.1", "react": "15.2.0", "react-native": "^0.28.0", "realm": "^0.14.1" }, "devDependencies": { "babel-core": "^6.10.4", "babel-preset-react-native": "^1.9.0", "chai": "^3.5.0", "enzyme": "^2.3.0", "mocha": "^2.5.3", "mockery": "^1.7.0", "react": "^15.2.0", "react-addons-test-utils": "^15.2.0", "react-dom": "^15.2.0", "react-native-mock": "^0.2.4" } }
Error when running npm test
/Users/jamiehayman/someApp/reactApp/node_modules/bindings/bindings.js:91 throw err ^
Error: Could not locate the bindings file. Tried: → /Users/jamiehayman/someApp/reactApp/node_modules/realm/build/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/build/Debug/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/build/Release/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/out/Debug/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/Debug/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/out/Release/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/Release/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/build/default/realm.node → /Users/jamiehayman/someApp/reactApp/node_modules/realm/compiled/6.2.2/darwin/x64/realm.node at bindings (/Users/jamiehayman/someApp/reactApp/node_modules/bindings/bindings.js:88:9) at Object. (/Users/jamiehayman/someApp/reactApp/node_modules/realm/lib/index.js:35:41)
at Module._compile (module.js:541:32)
at Module._extensions..js (module.js:550:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (realm.js:3:1)
at Module._compile (module.js:541:32)
at loader (/Users/jamiehayman/someApp/reactApp/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (dashboardContainer.js:9:1)
at Module._compile (module.js:541:32)
at loader (/Users/jamiehayman/someApp/reactApp/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (dashboardContainer.test.js:18:1)
at Module._compile (module.js:541:32)
at loader (/Users/jamiehayman/someApp/reactApp/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at /Users/jamiehayman/someApp/reactApp/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/jamiehayman/someApp/reactApp/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/Users/jamiehayman/someApp/reactApp/node_modules/mocha/lib/mocha.js:469:10)
at Object. (/Users/jamiehayman/someApp/reactApp/node_modules/mocha/bin/_mocha:404:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (node.js:348:7)
at startup (node.js:140:9)
at node.js:463:3
npm ERR! Test failed. See above for more details.