Questions tagged [node-addon-api]

node-addon-api is the C++ wrapper for N-API, the ABI stable library to build addons for Node.js.

126 questions
1
vote
2 answers

C++ N-API Multiple Type Signatures

I am learning C++ and playing around with OpenCV and node-addon-api. I wanted to create my own wrapper for cv::Vec. docs #include #include class Vec : public Napi::ObjectWrap { public: static Napi::Object…
Michal
  • 4,952
  • 8
  • 30
  • 63
1
vote
1 answer

Crash when invoking Promise::Defered.Resolve() in AsyncWork.OnOK function

I pass a Napi::Promise::Deferred to a AsyncWorker, and call Promise::Defered.Resolve() in AynscWork.OnOK. but it always crash when I call Resolve() // node addon function Napi::Promise FileMd5Async(const Napi::CallbackInfo& info) { Napi::Env…
QuinnChen
  • 670
  • 1
  • 8
  • 29
1
vote
2 answers

Problems running Napi on linux with callbackInfo

When using windows the Napi and I run npm i it compiles and works just fine. When doing the same on linux I get this error with the napi-inl.h project/node_modules/node-addon-api/napi-inl.h: In instantiation of ‘static Napi::Function…
F22lightning
  • 620
  • 6
  • 16
1
vote
1 answer

Store node-addon event natively for later callback

I have two events created in javascript which I can call successfully through node-addon-api. But I only can use them immediately after calling the addon function. Is there any way to save the function pointer for later usage? const emitter = new…
Martin
  • 123
  • 10
1
vote
1 answer

Adding two string arguments in Node Addons

I am trying to add two string arguments in my addon but I could not get it to work. I always get an error about the types of the two arguments. My function: void Add(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); …
Something Q
  • 125
  • 1
  • 7
1
vote
1 answer

Importing/requiring an NAPI addon from a Webpack ReactJS/ReactTS project

I have a custom API (closed source for now), built in pure C. This API is the client side of a communication protocol (think network-based database queries). I have successfully used node-gyp to compile the C code wrappers so that the NAPI addon…
Tristan Duquesne
  • 512
  • 1
  • 6
  • 16
1
vote
1 answer

node addon with cluster get process id returns same id for all forked process's

Edit GetCurrentProcessId() and getpid() return different values... but boost does not. Original question I am writing a node addon to add a local native cache to be used with an express server when running as a cluster, to have a common cache. I…
t348575
  • 674
  • 8
  • 19
1
vote
1 answer

How to create a new Buffer from a vector of char using node-addon-api?

I'm trying to create a new Buffer from a vector of char using node-addon-api, but the resulting Buffer's content is always different from the vector. Here is my cpp code: #include Napi::Value GetBuffer(const Napi::CallbackInfo& info) { …
Searene
  • 25,920
  • 39
  • 129
  • 186
1
vote
1 answer

How to pass an IUIAutomationElement between threads

I am writing a Node.js native Addon in C++ (using node-addon-api) to interact with Microsofts UIAutomation API. I am trying to listen to Focus Events, wrap the IUIAutomationElement which caused the event and pass the wrapped element to javascript. I…
1
vote
1 answer

How to link libnode.a to a shared library in linux

I'm porting a large C++ code from windows to linux. One part consists of a few shared libraries that contain node addons. My code compiles fine, but I get thousands of errors when linking to node. I recompiled node adding the -fPIC flag in the…
cauchi
  • 1,463
  • 2
  • 17
  • 45
1
vote
2 answers

Compile node-gyp C++ addon with Visual Studio 2017 or 2019

I'm trying to run Node C++ Addon example from https://github.com/nodejs/node-addon-examples/tree/master/1_hello_world/node-addon-api With commands: npm install node ./ I'm using Windows 10 with node.js v12.18.3 node-gyp v7.1.0 Have the following…
gscriptor
  • 93
  • 3
  • 11
1
vote
0 answers

Magick++/NAPI module memory leak

I'm writing a native module using node-addon-api that takes advantage of the Magick++ library. The module takes a file path to an image alongside some parameters and returns a buffer. I seem to have come across a pretty bad memory leak issue which…
Essem
  • 311
  • 2
  • 11
1
vote
0 answers

compiling a script employing lib2geom with cmake-js for use in N-API node.js addon

I am attempting to make use of lib2geom in an Electron app. I was able to write a script that employs the library to obtain an intersection of two paths and then wrap it with node-addon-api using examples from…
J. Barca
  • 538
  • 6
  • 19
1
vote
1 answer

Print node terminal/main.js log to renderer console (developer tools)

I have a electron app which is using c++ native addon in it. C++ code prints log to terminal and while development I can see them in termianl. Electron app log in renderer.js console (developer tools console). The same thing does not happen after…
1
vote
1 answer

Addons: TypeError: addons.function() is not a function

I'm still new into addons and such. I'm trying to run a simple c++ function that prints "Hello MIKE" into node js. However, I get this following error: TypeError: addons.greetHello is not a function at Object.
1 2 3
8 9