node.js-nan

Invoking some callback function twice leads to Segmentation fault: Nan

六眼飞鱼酱① 提交于 2019-12-11 03:35:16
问题 I am writing C++ addon using nbind - GitHub link for most thing and Nan - GitHub link for calling callbacks asynchronous. When I invoke callback only once, it works perfect. But When I invoke callback twice it gives Segmentation fault (core dumped) . Couldn't find error using gdb . Here is JS and C++ codes(compiling using node-gyp configure build ): //main.js code var nbind = require('nbind'); var lib = nbind.init().lib; lib.HeaderExample.callJS(function(a) { console.log("result" + a); });

Return a Nan::ObjectWrap from another Nan::ObjectWrap

六月ゝ 毕业季﹏ 提交于 2019-12-07 08:22:07
问题 I have two subclasses of Nan::ObjectWrap class Zyre: public Nan::ObjectWrap {...} class ZyreEvent: public Nan::ObjectWrap {...} How can I return a ZyreEvent javascript object from a method in Zyre ? I have the following method, in which I create a ZyreEvent : NAN_METHOD (Zyre::_recv) { Zyre *node = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ()); ZyreEvent *zyre_event = new ZyreEvent (node->self); info.GetReturnValue().Set(zyre_event->Wrap(info.This())); } But I can't Wrap the zyre_event

Error: Cannot find module 'nan'

荒凉一梦 提交于 2019-12-06 05:01:31
问题 I'm working on native Node.js addon and following nan docs I included nan into binding.gyp like: "include_dirs" : [ "<!(node -e \"require('nan')\")" ] Also nan is in npm dependencies. But when I install the package inside the another node module node-gyp is failed with error > nnb@1.0.2 install /Users/Shopgate/sandbox/stress/node_modules/nnb > node-gyp rebuild module.js:338 throw err; ^ Error: Cannot find module 'nan' at Function.Module._resolveFilename (module.js:336:15) at Function.Module.

Return a Nan::ObjectWrap from another Nan::ObjectWrap

帅比萌擦擦* 提交于 2019-12-05 17:10:25
I have two subclasses of Nan::ObjectWrap class Zyre: public Nan::ObjectWrap {...} class ZyreEvent: public Nan::ObjectWrap {...} How can I return a ZyreEvent javascript object from a method in Zyre ? I have the following method, in which I create a ZyreEvent : NAN_METHOD (Zyre::_recv) { Zyre *node = Nan::ObjectWrap::Unwrap <Zyre> (info.Holder ()); ZyreEvent *zyre_event = new ZyreEvent (node->self); info.GetReturnValue().Set(zyre_event->Wrap(info.This())); } But I can't Wrap the zyre_event because Wrap is a protected member. If I understand correctly, you want to return from (subclass of) Nan:

Error: Cannot find module 'nan'

蓝咒 提交于 2019-12-04 11:36:09
I'm working on native Node.js addon and following nan docs I included nan into binding.gyp like: "include_dirs" : [ "<!(node -e \"require('nan')\")" ] Also nan is in npm dependencies. But when I install the package inside the another node module node-gyp is failed with error > nnb@1.0.2 install /Users/Shopgate/sandbox/stress/node_modules/nnb > node-gyp rebuild module.js:338 throw err; ^ Error: Cannot find module 'nan' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at [eval]:1