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
1
vote
0 answers
C++ callbacks are not called for Node bindings
I'm stuck. It is the first time I use Node.js and javascript. I was trying to implement Node.js bindings for a library written in C++. I wrote them and tested with a simple console example and they worked. However, when I use http server, callbacks…

Alisher
- 59
- 6
1
vote
1 answer
Set a string to v8 Array
I investigate native Node addons using Nan.
So I'm trying to return back to Node an array of strings with the following code:
NAN_METHOD(open) {
Local v8Array = Nan::New();
std::string str = "erwer";
v8Array->Set(0,…

Rax Wunter
- 2,677
- 3
- 25
- 32
1
vote
0 answers
How to set a custom context for NanMakeCallback->Call
NAN 1.7.0 introduced an optional target parameter for NanCallbackCall. This parameter allows you to set the context for the callback i.e. this.
However not matter what I do the this value in my JavaScript callback is always the default Global…

xzyfer
- 13,937
- 5
- 35
- 46
0
votes
0 answers
C++ add-on does not run from inside express api route but works outside
I'm using a C++ add-on on my Node.js server. I'm trying to get the decrypt function which I imported from the file to run when the api is hit but the decrypt does nothing. Instead, when I leave the decrypt outside the route as commented, it works…

kashif197
- 23
- 3
0
votes
1 answer
How to convert int to string in nan, C++?
So, I got that:
void Method(const Nan::FunctionCallbackInfo& info) {
v8::Local context = info.GetIsolate()->GetCurrentContext();
int last_number = info[0]->NumberValue(context).FromJust();
…
0
votes
1 answer
Proper Method for Storing JavaScript Instances in Nan::ObjectWrap C++ Class
Let's say I have two classes that are developed in C++, but are exposed using Nan NodeJS native modules. For example, a "Sprite" and "Texture" class.
In the JavaScript, I want to be able to have a Sprite store a Texture as if it were just another…

Griffort
- 1,174
- 1
- 10
- 26
0
votes
1 answer
HandleOKCallback crash
Hi below code is crashing when i perform if check on argv[1]. Please help to
fix it, while assigning the value to argv[1] i need to check if bool variable checktrue is true assign string value else assign int value as below code.
void…

mohan
- 37
- 3
0
votes
1 answer
Why is my NAN_METHOD not recognized?
I get the following error when trying to run my Node native extension (it builds without error). I'd like to know why I'm getting this error, since I'm doing everything correctly as far as I can tell.
./NodeTest/nodeTest.js:7
tester.Startup();
…

Bungles
- 1,969
- 2
- 25
- 54
0
votes
1 answer
How do I create an ES6 class in V8 (for a Node.js native add-on)?
I'm writing a Node.js native add-on (with nan helper module).
I want to create and export an ES6 class value, whose type is "function" and .toString() is "class ... { ... }". Viz., I want to know the native equivalent of:
module.exports = class…

Константин Ван
- 12,550
- 7
- 61
- 73
0
votes
1 answer
Nan::To accepts all conversions
I'm trying to write an argument verification helper function but apparently Nan::To never fails to convert and object to T, even if the conversion is impossible.
//convert.cpp
template
bool argument_verify(Local const& in_value,…

ManicQin
- 159
- 1
- 8
0
votes
1 answer
How to pass a NEW Nan::ObjectWrap from C++ to Javascript?
I've defined the following wrapped class in my C++ Node extension.
class JSStatus : public Nan::ObjectWrap {
public:
long statusCode;
std::string statusMessage;
std::string statusDetails;
static NAN_MODULE_INIT(Init);
static…

Bungles
- 1,969
- 2
- 25
- 54
0
votes
1 answer
Using "os" module from native nodejs (electron) C++ code
I wonder if it is possible to use the "os" module internally in native module, without passing it over as a param from javascript.
It's one of the core nodejs/electron modules so I assume it should be available in native module internally some way…

Konstantin
- 339
- 2
- 15
0
votes
1 answer
Postgres driver in NodeJS C++ Addon
I'm currently developing a C++ addon for NodeJS using the abstraction layer Nan. I would like to make a PostgreSQL request from this addon. But I get the following error:
module.js:597
return process.dlopen(module, path._makeLong(filename));
…

Nomeho
- 156
- 1
- 5
0
votes
1 answer
How to get arbitrary sized buffers in nodejs using nan
I have a node js application that does some image processing on large files using sharp, which in turn uses nan to interface with node. When I load a very large image I get an error from nan that says
node: ../node_modules/nan/nan.h:679:…

matth
- 563
- 7
- 22
0
votes
2 answers
How to pass binary data from C++ to Node.js
I have a binary data in c++ variable buffer as below:
int len = 39767;
uint16_t * buffer = (uint16_t) malloc(len);
FILE * fp = fopen("rahul.jpg", "rb"); // size of file is 39767 byte.
fread(buffer, len, 1, fp);
fclose(fp);
fp = fopen("rahul3.jpg",…

Bimal Jha
- 391
- 2
- 14