0rpc / zerorpc-node

zerorpc for node.js
http://www.zerorpc.io
Other
705 stars 167 forks source link

NPM version error in electron #100

Open janleskovec opened 5 years ago

janleskovec commented 5 years ago

Ok this is probbably just a noob question but I keep getting this error when using zerorpc in electron.

error message:

Uncaught Error: The module '/home/jan/Development/musicled/node_modules/zeromq/build/Release/zmq.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620)
    at tryModuleLoad (internal/modules/cjs/loader.js:559)
    at Function.Module._load (internal/modules/cjs/loader.js:551)
    at Module.require (internal/modules/cjs/loader.js:658)
    at require (internal/modules/cjs/helpers.js:20)
    at Object.<anonymous> (/home/jan/Development/musicled/node_modules/zeromq/lib/index.js:6)
    at Object.<anonymous> (/home/jan/Development/musicled/node_modules/zeromq/lib/index.js:848)

dependencies in my package.json:

"dependencies": {
    "zeromq": "^4.6.0",
    "zerorpc": "^0.9.8"
},
"devDependencies": {
    "electron": "3.0.2"
},
"scripts": {
    "start": "electron ."
}

I have tried changing versions, running npm rebuild... no success.

What am I doing wrong? Thank you for your patience.

liangxinhui commented 5 years ago

+1

YeeTsai commented 5 years ago

+1

axfelix commented 5 years ago

Also here. I'm new to Electron but I have't been able to rebuild this module for current Electron successfully no matter what variant of rebuild I try, and I'm not sure if I should be using an older Electron or what.

Loyoan commented 5 years ago

I found solution. Use electron-rebuild can fix this issue: https://github.com/emersion/mpris-service/issues/11#issuecomment-323447746

axfelix commented 5 years ago

Trying to do that dies on zeromq when it loops through all the dependencies:

g++: error: ./Release/../../zmq/lib/libzmq.a: No such file or directory

I have libzmq.a provide by a zeromq system package, but I have no idea how these npm build tools are supposed to work, it's not finding it.

Alex-Mann commented 5 years ago

I got the same issue. I haven't had a chance to dive too deep into why this is happening but on my end, it was because it was missing the ZMQ C libraries. You can confirm this by cd-ing to the directory with this package.

cd <your_proj_dir>/node_modules/zeromq/build make

Should give you:

$   SOLINK_MODULE(target) Release/zmq.node
clang: error: no such file or directory: './Release/../../zmq/lib/libzmq.a'
make: *** [Release/zmq.node] Error 1

Then if you run the preinstall script to pull the libraries and everything else (go up one directory so you are in the root directory of zeromq). node scripts/preinstall.js That should run to completion and successfully build. You can confirm this by checking... ls zmq/lib And you should see: libzmq.a libzmq.la pkgconfig Now you should be able to go back to your project directory and get this to run.. if not try running electron-rebuild to get it to compile the binaries for the specific version of node that electron is using under the hood.

Hopefully I can debug a little more into this so that it works more seamlessly when upgrading verisons since this is hacky to have to do everytime you reinstall your node_modules

axfelix commented 5 years ago

Yeah, I got deep enough down that rabbit hole that I decided to stick to Electron 1.8.8 for the project I was working on, because that gets along with this version of zerorpc. There are some things I'd like to have that don't seem to work in that old version of Electron (like Notifications in the main process) that I'd still like to see this library updated due to the difficulty in recompiling it, though.

axfelix commented 5 years ago

FYI -- This will still work on newest Electron 2.x.x, which is still supported. It does not work on current Electron 3.x/4.x/5.x and I still haven't been able to recompile it successfully.

daniel0076 commented 5 years ago

you may use electron-rebuild to recompile zeromq against the installed electron version install Electron and then run ./node_modules/.bin/electron-rebuild Success with Electron 5.0.8

axfelix commented 5 years ago

@daniel0076 Were you able to rebuild under Windows too? I was able to get it working on Mac but not Windows.