zeromq in electron
ZeroMQ is a great socket library and very useful to use locally with electron to communicate to other processes. The module itself is beginning to age a bit and to use it requires a very specific setup.
-
Make sure you're running
Node v12
,npm 6.13.4
,electron 3.0.15
. Newer node and electron versions may work but it is trial and error. Note the electron here is years out of date and the goals of your project should be seriously considered before downgrading this much. -
npm install
like usual -
You may have to run the
preinstall.js
script if npm doesn't generate thelibzmq
libs. This step is very undocumented but has cost me many hours in the past. -
cd <your_proj_dir>/node_modules/zeromq/build
-
Run
make
-
Should give you this (I'm using clang in this case):
-
$ 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).
-
Run
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 runningelectron-rebuild
to get it to compile the binaries for the specific version of node that electron is using under the hood.