简体   繁体   English

如何为node.js安装zeromq

[英]how to install zeromq for node.js

I want to install zeromq for node.js in Windows 7 64-bit. 我想在Windows 7 64位中为node.js安装zeromq。 I tried with 我试过了

npm install zmq

It gave phython.exe is missing. 它给了phython.exe缺失。 After installing that python (2.7.3) . 安装那个python (2.7.3)
Again it gave some build error, which is as follows: 它再次给出了一些构建错误,如下所示:

C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe failed with exit code: 1

Update 1 更新1

Improvements were made, now npm install zmq works, but you still need Win SDK 7 and VS C++ 2010, I think. 现在npm install zmq正在进行改进,但我认为你还需要Win SDK 7和VS C ++ 2010。

Original Answer 原始答案

Unfortunately npm install zmq still don't work, but you can install it from local repo. 不幸的是, npm install zmq仍然无法正常工作,但你可以从本地repo安装它。

mscdex forked the zeromq.node repo, and added windows support, so just clone his zeromq.node mscdex分叉了zeromq.node repo,并添加了windows支持,所以只需克隆他的zeromq.node

But before build you need some prerequisites: 但在构建之前,您需要一些先决条件:

Run the Windows SDK 7.1 Command Prompt from Start menu / Microsoft Windows SDK v7.1 从“开始”菜单/ Microsoft Windows SDK v7.1运行Windows SDK 7.1命令提示符

go to the cloned directory, and type 转到克隆目录,然后键入

node-gyp configure
node-gyp build

this should work on windows 7 64bit. 这应该适用于Windows 7 64位。 I cloned zeromq.node into my node project dir, so in my app.js i could require('./zeromq.node') . 我将zeromq.node克隆到我的节点项目目录中,所以在我的app.js我可以require('./zeromq.node')

I had alot of trouble myself and eventually got it installed after hours of reading and trying diff things out: 我自己遇到了很多麻烦,最终在经过几个小时的阅读后安装了它并试图解决问题:

  1. Install python. 安装python。 Make sure Python 2.7.x installed and not 3.x (i used https://www.python.org but cygwin's python might work too) Confirm by running below: 确保安装Python 2.7.x而不是3.x(我使用https://www.python.org但cygwin的python也可以工作)通过运行以下方式确认:

    $ python -V Python 2.7.9

  2. set PYTHON env variable, whereever you installed it (or cygwin's bin directory if installing python that way): 设置PYTHON env变量,无论你安装它(或者cygwin的bin目录,如果以这种方式安装python):

    PYTHON=C:\\dev\\python\\python.exe PYTHON = C:\\ dev的\\蟒\\ python.exe

  3. Set what folder python.exe added onto your PATH variable: 设置python.exe添加到PATH变量的文件夹:

    PATH=C:\\dev\\python\\; PATH = C:\\ dev的\\蟒\\;

  4. needed this node-gyp installed manually: 需要手动安装这个node-gyp:

    $ npm install -g node-gyp ... Got slightly further...

  5. So I quit with trying to get it to install with my current Visual C++ 2010 and got Visual C++ 2012 to work (think 2013 may work too): so installed ' Visual Studio 2012 Express for Windows Desktop ' 所以我放弃尝试使用我当前的Visual C ++ 2010进行安装并使Visual C ++ 2012工作(想想2013可能也可以):所以安装了' Visual Studio 2012 Express for Windows Desktop '
    Should install the ' 2012 Visual C++ Redistributables ' (if not, install separately). 应该安装' 2012 Visual C ++ Redistributables '(如果没有,单独安装)。

    Also had ' Windows7 SDK ' already installed per balazs instructions so probably need that too. 还有每个balazs指令已安装' Windows7 SDK ',所以可能也需要它。

    Now try on Windows command line and specify the version to use: 现在尝试使用Windows命令行并指定要使用的版本:

    $ npm install --msvs_version=2012 zmq and it worked!

    Note: wanted to mention what I already had installed. 注意:想提一下我已安装的内容。 Already had 'Visual Studio C++ 2010 Express' installed (which installed Visual C++ 2010 Redistributables) and Windows7 SDK since I was kinda following balazs instructions above. 已经安装了'Visual Studio C ++ 2010 Express'(安装了Visual C ++ 2010 Redistributables)和Windows7 SDK,因为我有点遵循上面的balazs说明。

    Then I tried installing: 'Microsoft Visual Studio 2010 Service Pack 1' 'Visual C++ SP1 Compiler Update for Windows SDK 7.1' 然后我尝试安装:'Microsoft Visual Studio 2010 Service Pack 1''用于Windows SDK 7.1的Visual C ++ SP1编译器更新'

    Since none of that 2010 worked, I went with 2012. Maybe someone can figure out if possible to make it work with C++ 2010. 由于2010年没有一个工作,我去了2012年。也许有人可以弄清楚是否有可能使它适用于C ++ 2010。

我没有查看该软件包中的最新更改,但我为自己的项目编写了https://github.com/matthiasg/zeromq-node-windows ,它们对zeromq-node项目进行了一些小的更改,使其在Windows中运行。正如它在自述文件中所述,我不提供支持,但也许这会让你开始?

This thread was very useful, here's what worked for me today on Win10: 这个帖子非常有用,这就是今天在Win10上对我有用的东西:

  1. Download / install zmq binaries for windows 下载/安装Windows的zmq二进制文件
  2. Download / install node.js for windows 下载/安装windows的node.js.
  3. Get miniconda2 or similar in case you have python3 (python 2 required for the steps below build) 获得miniconda2或类似的以防万一你有python3(下面的步骤需要python 2)
  4. Get VS 2013 (any version should do) VS '15 doesn't work at this time 获取VS 2013(任何版本都应该这样做)VS '15目前不起作用
  5. From a python2 prompt: npm install --msvs_version=2013 zmq 从python2提示符: npm install --msvs_version=2013 zmq

The latest update: 最新更新:

Windows 8.1, node v4.4.5, npm v3.10.5 Windows 8.1,节点v4.4.5,npm v3.10.5

  1. Ensure python2 environment as usual 像往常一样确保python2环境
  2. Install Windows SDK (mine 8.1) 安装Windows SDK(我的8.1)
  3. Install VS2015 Community and select Common Tools for Visual C++ 安装VS2015社区并选择Visual C ++的常用工具
  4. ===> npm -g install npm@next see this ===> npm -g install npm@next看到这个
  5. npm install --msvs_version=2015 zmq

Note: I can't build with vs2012 anymore and all the suggested above not working with build error error c2240 cannot convert from 'v8::Value *' to 'v8:object *volatile' . 注意:我无法再使用vs2012进行构建,并且以上建议不使用构建错误error c2240 cannot convert from 'v8::Value *' to 'v8:object *volatile' Maybe because of the newer nodejs v4.4.5 (someone can clarify this?). 也许是因为更新的nodejs v4.4.5(有人可以澄清这个吗?)。

However using vs2015 produce build error win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2' . 但是使用vs2015会产生构建错误win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2' I fix this using npm@next as mentioned above. 如上所述,我使用npm@next修复此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM