Questions tagged [node.js-nan]

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

Docs

51 questions
3
votes
1 answer

How to use Nan::MakeCallback to send events from nodejs addon to javascript?

Forgive that I am a beginner for Node and Nan. Now, I want to send events from nodejs addon to javascript. v8::Local obj Nan::Persistent persistent; persistent.Reset(obj); v8::Local orig_obj =…
C. X. Pan
  • 31
  • 3
3
votes
1 answer

Node NAN: getting set fault calling GetFromPersistent in Execute method of AsyncWorker

I'm building a native extension for node which includes a long-running operation with a callback on completion. I am passing a node buffer to the call. It contains the payload of what is to be processed by the extension. I should be able to store…
Jim B.
  • 4,512
  • 3
  • 25
  • 53
2
votes
2 answers

How to know which of the several ways to make a C/C++ nodeJS addon is used by a particular example or repo?

Apparently a situation has evolved over the years where there are three, four, or five main ways to write a nodeJS addon in C/C++ depending on where you're reading about it. For those of us just trying to learn and write our first addon in 2021 it…
hippietrail
  • 15,848
  • 18
  • 99
  • 158
2
votes
0 answers

How do I package and consume my node native extension?

I've built my first node native extension and want to consume it in another node app, but I don't know which files need to be packaged up nor how they should be packaged for distribution & consumption by other apps. In the "build/release" directory…
Bungles
  • 1,969
  • 2
  • 25
  • 54
2
votes
1 answer

Checking instanceof in node.js addons using Nan

I am trying to verify that an object passed to a node addon is of the correct type before I unwrap it and start to use it. Here's the solution that I've cobbled together from looking at various sources on the web. Persistent…
bmacnaughton
  • 4,950
  • 3
  • 27
  • 36
2
votes
0 answers

nodejs c++ addon -- unable to node-gyp build using nan module

I am learning how to build C/C++ addons for nodejs. I could successfully node-gyp configure, node-gyp build and run node index.js on a simple hellow world program. So, my basic setup is working. The below code (copy-paste from official nodejs…
Mopparthy Ravindranath
  • 3,014
  • 6
  • 41
  • 78
2
votes
1 answer

Infrequent Segfault on Node.js/Nan Callback in C++ Addon

I'm making a NodeJS addon using the Nan library, and I'm running into an issue where calling a callback (created on the javascript side and passed to the addon to be executed asyncronously) will cause a segfault - but only about once every 10…
ChaseC
  • 121
  • 5
2
votes
1 answer

Make v8 object properties and methods visible to JS

I am wrapping a C++ object with node::ObjectWrap and I have some methods defined like: auto tpl =…
Sepehr
  • 2,051
  • 19
  • 29
1
vote
1 answer

nodejs native addon : how to modify the value of c++ object's member contained in another native addon

First some context, i got two nodejs native addon. The first one contains a static c++ object "Conn" exposed using an v8 object internal field as described in the embedder's guide NAN_METHOD(cobject) { auto isolate = Isolate::GetCurrent(); …
Mumrah81
  • 2,034
  • 2
  • 16
  • 23
1
vote
0 answers

Node C++ module vs libuv thread pool size

I've written a Nodejs C++ module that makes use of NAN's AsyncWorker to expose async module functionality. Works great. However, I understand that AsyncWorker makes use of libuv's thread pool, which defaults to just 4 threads. While this (or a…
logidelic
  • 1,525
  • 15
  • 42
1
vote
0 answers

Native Node.js addon callback error - The specified procedure could not be found

I am writing a custom Node.js addon. Everything works dandy except for the use of callbacks. I have a method in a DLL that requires registering a C++ function callback - it takes a function, and then calls it when it receives new data, which is…
Giallo
  • 785
  • 2
  • 10
  • 26
1
vote
1 answer

Passing an Array via nan returns undefined when attempting to retrieve

I'm currently writing a native addon for NodeJS using their c++/v8 system, and am attempting to write an array from Javascript, to C++ and later retrieve it. Whenever I attempt to retrieve a value from the array and return it, it returns an empty…
N.J.Dawson
  • 1,220
  • 10
  • 28
1
vote
0 answers

How to use complex v8 datatypes in an async worker class of a native node module?

I try to make my node module methods asynchronous. I created an AsyncWorker Class but stumbling on a few things :/ My Nan::AsyncWorker looks as follows... class PackerWorker : public Nan::AsyncWorker { public: PackerWorker(Nan::Callback…
Stephan Ahlf
  • 3,310
  • 5
  • 39
  • 68
1
vote
1 answer

Conversion between v8::value to date

I am writing C++ addon on v8 using nan. One of the arguments to constructor is of Date type. IsDate returns true, but I don't know how to convert it to C++ Date object to get Year, Month and Day and etc.. void NodeObject::New(const…
user2391685
  • 1,006
  • 12
  • 16
1
vote
1 answer

SetWindowsHookEx in a node.js module using node-nan

I'm trying to create an Electron node.js application that can perform certain functions using global keybindings. The global keybindings API in Electron doesn't work in games unfortunately so I need to create a native node module that listens to…
Rohan
  • 8,006
  • 5
  • 24
  • 32