NodObjC: when electron update to 1.2.1 the NodObjc it does not work

@TooTallNate
Hi TooTallNate, I have a problem when my electron from 1.1.1 update to 1.2.1 when it use nodobjc call objective-c framework like this: app threw an error during load

TypeError: error setting argument 0 - writePointer: Buffer instance expected as third argument
at TypeError (native)
at Object.writePointer (/Users/apple/talk/electron-quick-start-master/node_modules/ref/lib/ref.js:742:11)
at Object.set (/Users/apple/talk/electron-quick-start-master/node_modules/ref/lib/ref.js:484:13)
at Object.alloc (/Users/apple/talk/electron-quick-start-master/node_modules/ref/lib/ref.js:516:13)
at Object.proxy as objc_getClassList
at Object.getClassList (/Users/apple/talk/electron-quick-start-master/node_modules/nodobjc/lib/core.js:111:20)
at Object.importFramework (/Users/apple/talk/electron-quick-start-master/node_modules/nodobjc/lib/import.js:321:26)
at Function.framework (/Users/apple/talk/electron-quick-start-master/node_modules/nodobjc/lib/index.js:225:18)
at Object. (/Users/apple/talk/electron-quick-start-master/main.js:14:9)
^C

I need your help,thanks.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 3
  • Comments: 17 (1 by maintainers)

Most upvoted comments

@imlliu2005 @matheuss @slaskis @TooTallNate @greenimpala @kmartinezmedia @atdrago

I haven’t been coding for long, so forgive me if this is a little long winded ( I think I have a solution to this issue ):

I’m using Electron v1.4.5 & node v7.0.0 & I’m getting this error: Error: Module version mismatch. Expected 50, got 51.

In case it helps understand this a little further, I think the 50 in Expected 50, got 51 relates to the following:

cd node_modules/electron/dist/Electron.app/Contents/MacOS
./Electron --abi`
//50

And the 51 in Expected 50, got 51 relates to this:

node -p process.versions
//returns:
{ http_parser: '2.7.0',
  node: '7.0.0',
  v8: '5.4.500.36',
  uv: '1.9.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '57.1',
  modules: '51',
  openssl: '1.0.2j' }

So, to get Electron & NodObjC working again, run this in the root of your project directory:

npm rebuild --runtime=electron --target=1.4.5 --disturl=https://atom.io/download/atom-shell --abi=50

The --target you can get from your project, like this:

cd node_modules/electron/dist/Electron.app/Contents/MacOS
./Electron --version
// which for me returns 1.4.5

and the --abi you can get from your project too, like this:

cd node_modules/electron/dist/Electron.app/Contents/MacOS
./Electron --abi`
// which for me returns 50

This worked for me, and I was pretty happy with myself !

Just for completeness, here is the original full error:

App threw an error during load
Error: Module version mismatch. Expected 50, got 51.
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:178:20)
    at Object.Module._extensions..node (module.js:583:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:178:20)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at bindings (/Users/rootscript/Github/elm0171-electron145/node_modules/bindings/bindings.js:76:44)

Hope this helps you guys (until Electron & Node get there versions synced)

Any info/workaround/fix on this? 😕

const macOS = require('nodobjc');

macOS.framework('Foundation');
macOS.framework('AVFoundation');
❯  node --version && electron --version
v6.3.0
v1.3.3
❯ npm start

> focus@0.1.0 start /Users/matheus/dev/node/focus
> electron .

App threw an error during load
Error: Module version mismatch. Expected 49, got 48.
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:167:20)
    at Object.Module._extensions..node (module.js:568:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:167:20)
    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 bindings (/Users/matheus/dev/node/focus/node_modules/bindings/bindings.js:76:44)

I think the reason is that node hasn’t updated v8 to 5.1+ yet, while Electron has.

At least in node 6.3.0:

$ node -p process.versions
{ http_parser: '2.7.0',
  node: '6.3.0',
  v8: '5.0.71.52',
  uv: '1.9.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '57.1',
  modules: '48',
  openssl: '1.0.2h' }