TooTallNate / NodObjC

The Node.js ⇆ Objective-C bridge

Home Page:http://tootallnate.github.io/NodObjC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when trying to run example code in Electron

gziolo opened this issue · comments

In package.json I added:

"nodobjc": "2.0.0",

npm install fails for the latest Node 4.x version.

When executing npm install on Node 0.12.9 I see those warnings:

../src/callback_info.cc:151:12: warning: 'NanThrowError' is deprecated [-Wdeprecated-declarations]
return THROW_ERROR_EXCEPTION_WITH_STATUS_CODE("ffi_prep_closure() Returned Error", status);
^
../src/ffi.h:25:54: note: expanded from macro 'THROW_ERROR_EXCEPTION_WITH_STATUS_CODE'

define THROW_ERROR_EXCEPTION_WITH_STATUS_CODE(x, y) NanThrowError(x, y)

                                                 ^

../node_modules/nan/nan.h:741:34: note: 'NanThrowError' has been explicitly marked deprecated here
NAN_DEPRECATED NAN_INLINE void NanThrowError(

but at least I'm able to install it.

When I try to run code (I just copied over Hello World example using Electron I see this error:

Uncaught Exception:
Error: Module version mismatch. Expected 47, got 14.
at Error (native)
at process.module.(anonymous function) as dlopen
at Object.Module._extensions..node (module.js:450:18)
at Object.module.(anonymous function) as .node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at bindings (/project/node_modules/nodobjc/node_modules/ref/node_modules/bindings/bindings.js:76:44)
at Object. (/project/node_modules/nodobjc/node_modules/ref/lib/ref.js:5:47)

Any ideas what I'm doing wrong?

This looks like similar issue electron/electron#2217. Error stack trace looks very similar, but error message is different.

There were 2 steps involved to fix this issue:

  1. https://www.bountysource.com/issues/27757822-npm-install-nodobjc-failing-due-to-ffi-and-node-4-x-incompatibility - I followed this page and used GitHub master version instead of npm package.
  2. Each time npm install is executed you need to execute this command:

./node_modules/.bin/electron-rebuild

to rebuild the native addon part of NodObjC.