Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM version error in electron #100

Open
janleskovec opened this issue Dec 15, 2018 · 10 comments
Open

NPM version error in electron #100

janleskovec opened this issue Dec 15, 2018 · 10 comments

Comments

@janleskovec
Copy link

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
Copy link

+1

1 similar comment
@YeeTsai
Copy link

YeeTsai commented Jan 8, 2019

+1

@axfelix
Copy link

axfelix commented Jan 9, 2019

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
Copy link

Loyoan commented Jan 11, 2019

I found solution. Use electron-rebuild can fix this issue:
dbusjs/mpris-service#11 (comment)

@axfelix
Copy link

axfelix commented Jan 14, 2019

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
Copy link

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
Copy link

axfelix commented Jan 31, 2019

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
Copy link

axfelix commented May 7, 2019

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
Copy link

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
Copy link

axfelix commented Aug 1, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants