Tag: gyp

从node-gyp调用make

我正在使用node-gyp构build一个在Linux上用C ++编写的本地Node.js插件。 加载项依赖于另一个共享库。 这个库目前不是用gyp构build的,它只是一个makefile。 如果我先构build共享库,然后在我的binding.gyp文件的主目标中构build指定“libraries”值的附加组件,则一切正常。 但是,我想要做的是通过在共享库的makefile上调用make,从node-gyp进程内的源代码构build共享库。 我尝试使用'action'属性添加一个依赖的目标到附加的binding.gyp并使主目标依赖于它: { "target_name": "other_library", "type": "none", "actions": [ { "action_name": "build_other_library", "inputs": [], "outputs": [ "/path/to/build/output/libother.so" ], "action": [ "make", "-C", "/path/to/makefile" ] } ] } 这不完全工作。 它正在发现其他makefile和make正在启动(我可以看到这发生与–verbose设置),但生成文件不正确执行。 GNU make的隐式构build规则似乎在共享库的makefile运行时被压制。 这意味着.cc和.cpp文件不被编译为.o文件。 我意识到node-gyp本身就是从binding.gyp中的目标生成一组加载项的makefile文件,共享库的makefile文件正在从其中生成。 它是否inheritance了node-gyp的make设置,包括抑制内置规则? 有没有办法解决它? (除了向共享库的makefile中添加显式构build规则)? (我已经尝试用$(MAKE)replacemake,这没有什么区别)。 编辑: 在共享库上运行GNU make,使用shell指定的-d(即node-gyp之外),为典型源文件search隐式规则如下所示: Considering target file `code.o'. File `code.o' does not exist. Looking […]

如何使用node-gyp根据节点版本有条件地编译node.js的本地代码?

我为node.js模块编写了一些C ++代码,这个模块是为节点0.8和增强的libuv编写的。 具体来说,我使用的是uv_mutex_ *函数,它不包含在节点0.6中包含的libuv中。 我想有条件地embedded这些函数的pthreads等价物,但是只有在旧版本的基础上构build。 如果节点版本为0.6,这应该使我在build立在节点0.8上的跨平台构build(Windows和Linux)和正常运行的Linux版本。 是否有节点版本的预处理器#define? 我找不到一个。 我能想到的最好的办法是在binding.gyp中做一些kludgy的东西来尝试猜测基于<@(node_root)的版本,并以某种方式将其按到“定义”值中。 一定会有更好的办法!

node-canvas在Node中工作,但在PhantomJS中需要时会失败

我有一个PhantomJS应用程序,我想从JS驱动页面(通过page.renderBase64('PNG') )获取一系列截图,然后将这些截图page.renderBase64('PNG')到GIF中。 据我所知,Node中没有办法用纯的base64string来构buildGIF,我真的不想把每一帧写到磁盘上,然后到Node外面用ImageMagick或类似的东西把它们缝在一起这会大大减缓这个过程。 所以我的计划是将base64图像绘制到canvas上,然后将canvas添加到Node GIF生成器。 虽然我可以在节点环境中使用node-canvas ,但是在我的Phantom脚本中包含require('canvas')时,当我启动一个新的Canvas对象时,吐出了缺less依赖关系时常见的错误: Error: Cannot find module './lib/node-canvas/build/Release/canvas' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require 我想,问题的一部分就是Phantom正在不同的环境中运行Node,而不是所有的依赖都不存在。 但是我不太了解Node和PhantomJS在执行Javascript方面的不同。 我不清楚什么是phantomjs://platform/bootstrap.js是否是我可以扩展的东西。 为了清楚起见,我正在使用Phantom-Node桥,在那里我用var page = require('webpage').create(); 。 然后我使用phantomjs从命令行执行脚本。 TL; DR:从PhantomJS脚本中需要基于C ++的Node模块node-canvas,它会失败,从Node运行时不会失败。 环境如何不同? 为什么一些Node模块工作而其他模块却不工作? 更新:我知道我可以在由Phantom渲染的页面上创build一个<canvas>元素并使用它,但是这需要在页面的沙箱化JS和页面之间来回耗费大量时间脚本本身。

错误:'REPLACE_INVALID_UTF8'不是'v8 :: String'的成员

所以我想在Raspbian中构build这个nodejs工具 。 所以作为说明说我需要npm install我继续前进,安装节点与apt-get: sudo apt-get install nodejs npm 然后我尝试编译/安装,我得到这个错误: $ npm install > configure@0.0.1 install /home/pi/Documents/Code/buzzerbot9000/node_modules/configure > node install.js sh: 1: node: not found npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! configure@0.0.1 install: `node install.js` npm ERR! […]

CMake或gyp for node.js插件开发

在大多数教程中,他们使用gyp作为C ++ node.js附加开发的构build系统。 但是,与gyp相比,CMake有着悠久的历史和更多的文档。 因此,我的问题是:哪一个更适合node.js C ++插件的开发? 谢谢。

电子本机添加:DLL初始化例程失败

我正尝试将我的C ++库作为本地附加组件连接到我的电子应用程序。 我能够运行node-gyp重build并生成一个成功的.node文件。 但是,当我尝试从main.js调用它,我得到一个错误,说:“dynamic链接库(DLL)初始化例程失败”。 我的binding.gyp文件如下所示: { 'targets': [ { # Usual target name/sources, etc. 'target_name': 'myclass', 'sources': [ 'myclass.cc', 'addon.cc' ], 'libraries': ["../libs/api.lib", "../libs/core.lib", "../libs/camera.lib", "../libs/algo.lib", "../libs/ComCtl32.lib", "../../deps/windows/opencv/lib/x64/*.lib", "../../deps/windows/tbb/lib/x64/*.lib"], 'include_dirs': ["<!(node -e \"require('nan')\")"], 'configurations': { 'Debug': { 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': '3' # /MDd }, }, }, 'Release': { 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': […]

安装NodeJS contextify包会产生错误

我是1个小时进入NodeJS,所以忍受着我。 我的项目需要的一个包是JSDom。 在刺激了大部分互联网之后,我发现JSDOm有一个名为contextify的依赖关系,这在某种程度上是在JSDom安装本身内部处理的。 所以这就是我所做的: sudo npm install jsdom 一切顺利,直到我得到以下几点: gyp WARN install got an error, rolling back install gyp ERR! rebuild error Error: EACCES, stat '/root/.node-gyp/0.8.2' gyp ERR! not ok npm ERR! contextify@0.1.7 install: `node-gyp rebuild` npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1 npm ERR! npm ERR! Failed at the contextify@0.1.7 install script. […]

在npm安装期间,在mac 10.5.8上findnode-gyp'pkg-config:command not found'

试图在github项目的mac-osx上进行npm安装。 不要在packages.json中看到pkg-config为什么node-gyp期望这样? 好像node-gyp应该包含pkg-config。 我认为这是节点工作的方式。 安装一个软件包,它可以根据需要进行安装。 我想这是不同的。 也想知道哪个版本的pkg-config其寻找。 是的,我一直在那里下载压缩包,但它的mac安装说明真的是无稽之谈。 它保持./configure然后进行安装。 但是,makefile不可用,一切都在同一目录级别,但它说cd到代码目录等 > node-gyp重build / bin / sh:找不到pkg-config:命令 gyp:调用'pkg-config libzmq –libs'返回退出状态127.试图加载binding.gyp gyp ERR! configuration错误 gyp ERR! 堆栈错误:`gyp`失败,退出代码:1 gyp ERR! 在ChildProcess.onCpExit(/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16) gyp ERR! 在ChildProcess.emit(events.js:98:17) gyp ERR! 在Process.ChildProcess._handle.onexit(child_process.js:820:12) gyp ERR! 系统达尔文12.5.0 gyp ERR! 命令“node”“/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js”“rebuild” gyp ERR! cwd / Users / Mac1 / Downloads / projdirectory / node_modules / zmq […]

在node-sqlite3中使用Gyp中的共享库

我是Gyp的新手。 而不是编译我的依赖,我想使用共享库,特别是已经在我的机器上的libsqlite3.so。 主要binding.gyp目前看起来像 { 'targets': [ { 'target_name': 'node_sqlite3', 'sources': [ 'src/database.cc', 'src/node_sqlite3.cc', 'src/statement.cc' ], 'dependencies': [ 'deps/sqlite3/binding.gyp:sqlite3' ] } ] } 我如何改变这个,以便使用共享的sqlite3库? deps文件夹中的binding.gyp有一个如下所示的部分。 我不认为我需要gyp为我做任何编译的sqlite3,所以切换types为shared_library可能不是正确的答案。 'targets': [ { 'target_name': 'sqlite3', 'type': 'static_library', 'include_dirs': [ '.' ], 'direct_dependent_settings': { 'include_dirs': [ '.' ], 'defines': [ 'SQLITE_THREADSAFE=1', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_RTREE' ], }, 'defines': [ '_REENTRANT=1', 'SQLITE_THREADSAFE=1', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_RTREE' […]

NodeJS npm安装pg失败

我试图npm安装pg在我的Ubuntu的虚拟机,我得到错误: > pg@1.1.0 install /usr/local/lib/node_modules/core/node_modules/pg > node-gyp rebuild || (exit 0) gyp: binding.gyp not found (cwd: /usr/local/lib/node_modules/core/node_modules/pg) while trying to load binding.gyp gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12) gyp […]