4

我需要安装zerorpc. 如文档中所述,我首先安装zeromq然后尝试了此命令:npm install -g zerorpc但我收到此错误:-

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

包.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"
  }
}

节点版本:v10.15.1 npm 版本:6.4.1

我所指的文章的链接

怎么解决,求大神帮忙!!

4

3 回答 3

3

不要使用 'zerorpc' 并使用 'zeromq' 来通信 nodejs 和 python。

请使用“ https://zeromq.org/languages/python/ ”安装Python,使用“ https://zeromq.org/languages/java/ ”安装nodejs

蟒蛇:点安装pyzmq

nodejs:npm install zeromq@5

----python代码----

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代码----

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);
                });
            }
);

测试python代码图像

测试 nodejs 代码图像

运行屏幕图像

于 2020-11-10T14:36:56.403 回答
0

操作系统:Mac

最终解决方案:将node版本从v8.17.0降级v13.5.0

于 2019-12-27T10:03:47.830 回答
-1

从你的日志看,好像zeromq没有安装成功,建议你再次运行

npm install --save zeromq

安装成功后,你可以继续运行你的npm install --save zerorpc.


编辑:我建议你在package.json这里做一些小游戏,完全删除node_modules目录,然后打开你的package.json并替换

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

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

然后运行npm install

让我知道事情的后续。

于 2019-02-16T08:34:10.483 回答