nodeJS 插件node-gyp环境配置(各平台)

当我们需要通过jsvascript调用C++库时,nodeJS为我们提供了C++模块的编译工具–node-gyp。
下面是关于node-gyp的环境配置。
1.首先我们需要安装node-gyp工具。(npm install -g node-gyp)

You will also need to install:

On Unix:

python (v2.7 recommended, v3.x.x is not supported)
make
A proper C/C++ compiler toolchain, like GCC
On Mac OS X:

python (v2.7 recommended, v3.x.x is not supported) (already installed on Mac OS X)
Xcode
You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
This step will install gcc and the related toolchain containing make
On Windows:

Visual C++ Build Environment:

Option 1: Install Visual C++ Build Tools using the Default Install option.

Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

[Windows Vista / 7 only] requires .NET Framework 4.5.1

Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7 (or see below for further instructions on specifying the proper Python version and path.)

Launch cmd, npm config set msvs_version 2015

If the above steps didn’t work for you, please visit Microsoft’s Node.js Guidelines for Windows for additional tips.

此处贴出node-gyp原文资料。

小白目前只配置了windows下的环境,测试成功。
总结环境需求就是
1.python 2.7 - 3.0版本之间
2..NET Framework 4.5.1
3. 一个Visual C++编译工具(除了资料的2015,2013本人测试也通过)
4.环境变量配置。(注:python安装位置需要添加到环境变量)

还有一点,上面的操作都做完之后,请执行node-gyp list 查看
这里写图片描述
注意倒数第二行,此处小白已经配置好了,如果没有配置的情况下,请根据提示操作。此处,下载了node.lib 静态库。虽然小白没有试过缺少这个node.lib库会怎样。不过看名字想想,对应我们的demo中node.h头文件想想,恐怕这个lib是不能缺少的。

最后为大家贴上参考资料:https://www.npmjs.com/package/node-gyp

阅读更多
文章标签: nodejs 插件
个人分类: nodeJS
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭