Native Abstractions for Node.js: A header file filled with macro and utility goodness for making native add-on module development easier across all major releases of Node.js
Questions tagged [node.js-nan]
51 questions
37
votes
6 answers
Error: Cannot find module 'nan'
I'm working on native Node.js addon and following nan docs
I included nan into binding.gyp like:
"include_dirs" : [ "

Rax Wunter
- 2,677
- 3
- 25
- 32
24
votes
2 answers
Node JS addons - NAN vs N-API?
I am looking to working on a project using node js addons with C++. I came across two abstract library NAN and N-API that I can use. However I am unable to decide which one I should use. I was not able to find proper comparison between these two…

The Prenx
- 483
- 4
- 15
9
votes
1 answer
How do I return a native object from a class derived from Nan::ObjectWrap?
I have two simple classes A and B that I'm trying to expose in a native module in node.js. A is directly creatable, but a B is only created by calling A::foo().
class Internal {};
class B {
public:
Internal internal;
explicit B(Internal…

Michael Anderson
- 70,661
- 7
- 134
- 187
5
votes
2 answers
Most basic example of adding a OpenCV C++ add-on to node.js
So lately I've been getting into OpenCV with C++.
I've built up a few libraries and apps that I would like to export over to Nodejs, but I can't figure it out for the life of me.
I tried to check out how he did it in this repo below, but it was a…

Bk Razor
- 1,492
- 1
- 14
- 24
5
votes
2 answers
Pass arbitrary Javascript data object to Node.js C++ addon
I have a Node.js addon written in C++ using Nan. Works fantastically. However, I've not been able to figure out how to have my Node Javascript code pass an arbitrary data object (ex. {attr1:42, attr2:'hi', attr3:[5,4,3,2,1]}) to the C++ addon.
Until…

logidelic
- 1,525
- 15
- 42
5
votes
1 answer
node.js Nan: call JavaScript callback in C++ function
I’m building a node-module wrapper for a C++ library to pass logging information through Nan to JavaScript. For this a NAN_Method is available to register a callback. The callback handler has to register itself as a callback at the C++ library via…

S.B.
- 51
- 1
- 4
5
votes
1 answer
This vs. Holder for ObjectWrap::Unwrap
The v8::FunctionCallbackInfo class distinguishes between This and Holder. I know what this is in JavaScript, and assume that This reflects that setting. But I have only a vague notion of what Holder is, and very little idea as to when I should use…

MvG
- 57,380
- 22
- 148
- 276
4
votes
1 answer
Return a Nan::ObjectWrap from another Nan::ObjectWrap
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…

Damiaan Dufaux
- 4,427
- 1
- 22
- 33
4
votes
1 answer
NodeJS Addon calling Javascript callback from inside NAN AsyncWorker::Execute
I would like to call a nodejs callback from within my asynchronous addon function. I have seen the synchronous example (here)
and I am using a wonderful asynchronous example (here) as a starting base.
However, when I try to execute a callback that…

EToreo
- 2,936
- 4
- 30
- 36
4
votes
0 answers
Is it possible to compose Maybe operations with the new version of Nan?
Nan 2.0, for compatibility with Node 4.0, introduced Maybe and MaybeLocal types, and several functions that return them. However, most of them do not seem to accept Maybe objects, and in several cases I would want to compose those methods. For…

murgatroid99
- 19,007
- 10
- 60
- 95
3
votes
1 answer
Some progress.Send calls not making it to nodejs land
I've made a Node addon using AsyncProgressWorker thread to handle my socket messages. Here is my code:
class ProgressWorker : public AsyncProgressWorker {
public:
ProgressWorker(
Callback *callback
, Callback *progress)
:…

Phenelo
- 95
- 1
- 8
3
votes
2 answers
Invoking some callback function twice leads to Segmentation fault: Nan
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).…

Jasurbek Nabijonov
- 1,607
- 3
- 24
- 37
3
votes
1 answer
Migrating old Addons to NAPI
I'm new to Node.js addons, I don't understand the difference between nan and n-api.
And is there an easy way to migrate an addon for old version (node v.0) to a newer version (node v.8)?

Idkingz
- 31
- 1
3
votes
1 answer
nodejs addon async callback with libuv
I have a node js service that calls into a native C library. The native library, fire events repeatedly and continuously. These events are delivered to a C callback function. My goal is to call a Javascript callback from this native C…

S. Vaghar
- 191
- 1
- 1
- 7
3
votes
2 answers
My data disappears when passing buffer to NodeJS from C++
I Have the following situation that I don't understand. I have an app where from NodeJS I'm calling a C++ function using Nan. The code on the C++ side is as follows:
#include
#include
using namespace std;
using namespace…

David Gatti
- 3,576
- 3
- 33
- 64