4

I need to install zerorpc. As mentioned in documentation i first installed zeromq then tried this command : npm install -g zerorpc but I am getting this error :-

C:\WINDOWS\system32>npm install -g zerorpc

> zeromq@4.6.0 install C:\Users\Admin\AppData\Roaming\npm\node_modules\zerorpc\node_modules\zeromq
> node scripts/prebuild-install.js || (node scripts/preinstall.js && node-gyp rebuild)


prebuild-install WARN install No prebuilt binaries found (target=10.15.1 runtime=node arch=x64 platform=win32)

Downloading libzmq for Windows
Download finished

C:\Users\Admin\AppData\Roaming\npm\node_modules\zerorpc\node_modules\zeromq>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "node C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'C:\Users\Admin\AppData\Roaming\npm\node_modules\zerorpc\node_modules\zeromq\node C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zeromq@4.6.0 install: `node scripts/prebuild-install.js || (node scripts/preinstall.js && node-gyp rebuild)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zeromq@4.6.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2019-02-16T04_42_24_207Z-debug.log

package.json

{
  "name": "pretty-calculator",
  "version": "1.0.0",
  "description": "A minimal Electron and Python - based calculator ",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "repository": "https://github.com/fyears/electron-python-example",
  "keywords": [
    "Electron",
    "Python",
    "zerorpc",
    "demo"
  ],
  "author": "fyears",
  "license": "MIT",
  "dependencies": {
    "zerorpc": "git+https://github.com/0rpc/zerorpc-node.git"
  },
  "devDependencies": {
    "electron": "^1.7.6",
    "electron-packager": "^9.0.1"
  }
}

node version : v10.15.1 npm version : 6.4.1

Link of article i was referring.

How to resolve it please help please!!

Nihal Karne
  • 59
  • 1
  • 6

3 Answers3

3

Do not use 'zerorpc' and use 'zeromq' to communicate nodejs and python.

Please install Python using 'https://zeromq.org/languages/python/' and nodejs using 'https://zeromq.org/languages/java/'

python : pip install pyzmq

nodejs : npm install zeromq@5

---- python code ----

import zmq

context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://127.0.0.1:5502")

for counter in range(0, 100001):
    socket.send(b"Hello")
    message = socket.recv()

    if counter % 1000 == 0:
        print(message, counter)

---- nodejs code ----

var zeromq = require("zeromq");

var socket = zeromq.createSocket('rep');

socket.bind("tcp://127.0.0.1:5502",
            function(err)
            {
                if (err) throw err;
                console.log("Bound to port 5502.");

                socket.on('message', function(envelope, blank, data)
                          {
                              console.log(envelope.toString('utf8'));
                              socket.send(envelope.toString('utf8') + " Blancmange!");
                          });

                socket.on('error', function(err) {
                    console.log("Error: "+err);
                });
            }
);

TEST python code image

TEST nodejs code image

running screen image

Hong승원
  • 122
  • 6
0

OS: Mac

Final solution: Downgrade node version from v13.5.0 to v8.17.0

crifan
  • 12,947
  • 1
  • 71
  • 56
  • Downgrading Nodejs from lts/fermium(14.15.1) to lts/dubnium(10.23.0) did the trick for me. – Ikun Dec 11 '20 at 22:18
-1

From your log, it looks like zeromq was not installed successfully, I will suggest you again run

npm install --save zeromq

after it has installed successfully, then you can go ahead and run your npm install --save zerorpc.


Edit: I will suggest you do some little play around with your package.json here, delete the node_modules directory completely, then you open your package.json and replace

"dependencies": {
  "zerorpc": "git+https://github.com/0rpc/zerorpc-node.git"
},

with

  "dependencies": {
    "zeromq": "^5.1.0",
    "zerorpc": "^0.9.8"
  },

then run npm install

let me know how it goes.

antzshrek
  • 9,276
  • 5
  • 26
  • 43
  • yes zeromq is installed i think so bcz when i run the command `npm -v zeromq` it shows `6.4.1` – Nihal Karne Feb 16 '19 at 11:15
  • @NihalKarne `npm -v zeromq` has nothing to do with your installation, it only tells your the version of `zeromq` you have installed. – antzshrek Feb 16 '19 at 11:26
  • I thought If its installed succesfully then only it will execute that command. I run `npm install zeromq` many times output is `+ zeromq@5.1.0 updated 1 package in 2.846s` So now what should I do? – Nihal Karne Feb 16 '19 at 11:38
  • can you try running the installation not on global mode? I mean `npm install --save zeromq` then let's see the outcome – antzshrek Feb 16 '19 at 13:39
  • I ran the command in the project folder i got this : `> node scripts/prebuild-install.js || (node scripts/preinstall.js && node-gyp rebuild) + zeromq@5.1.0 removed 5 packages, updated 1 package and audited 739 packages in 3.702s` – Nihal Karne Feb 16 '19 at 14:01
  • great! I guess you have a go then. Confirm you got it installed fine by starting your app so that you can be sure you don't have any broken dependencies. – antzshrek Feb 16 '19 at 14:11
  • No again the same error when i ran `zerorpc` install command. I dont know why this is happening. – Nihal Karne Feb 16 '19 at 16:32
  • `npm -v zeromq` return `6.4.1` ; for `npm install -g zeromq` output msg is `zeromq@5.1.0` and in the above error we can see `zeromq@4.6.0` So what is wrong why cant i complete the zerorpc installation. Please I need this for my code execution. – Nihal Karne Feb 16 '19 at 16:38
  • what version of npm and node are you using? – antzshrek Feb 16 '19 at 18:02
  • can you update your question with your `package.json`? – antzshrek Feb 16 '19 at 18:14