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
1 answer

Opencv4nodejs addon for cv::createLineSegmentDetector() function crashed. Exception can only be caught by catch(...). How to debug type of exception?

I am trying to make an integration of cv::LineSegmentDetector to opencv4nodejs which is an node addon of opencv (link: https://github.com/justadudewhohacks/opencv4nodejs). I have successfully complied an opencv4nodejs module which get loaded by…
Ayan Banerjee
  • 121
  • 2
  • 12
1
vote
0 answers

Pass package.json commands from a js file

I am working on a node.js native addon. While building for 32bit and 64 bit I have to set two different command for two different field. for 32bit "scripts": { "install": "cmake-js compile cmake -G \"Visual Studio 16 2019\" -A…
AtiqGauri
  • 1,483
  • 13
  • 26
1
vote
1 answer

String return limit in napi

I want to port some C++ code to js using napi (node-addon-api). The code is a search handler that returns string. So I wanted to know if there is any size limit in napi in returning strings?
1
vote
3 answers

"The specified module could not be found" when using a custom nodejs addon

I am writing a nodejs addon that depends on OpenGL (glfw). It compiles successfully but when I try and use it in node I get the error The specified module could not be found. This is the problematic part of the addon C++ code: #include…
chrispytoes
  • 1,714
  • 1
  • 20
  • 53
1
vote
1 answer

Passing on a C library callback to a NodeJS EventEmitter using node-addon-api

I am currently working on writing a node module that binds Alex Diner's cross-platform gamepad code using the Node-Addon-API. For the most part, this was a fairly easy task. Only problematic are the callback functions of the Gamepad library. My idea…
Julian Z.
  • 487
  • 6
  • 11
1
vote
1 answer

How to send object with buffer from addon to node threadsafe?

I am trying to send an object from addon to node but get: no matching function for call to ‘Napi::Object::New(Napi::Env&, Napi::Object&)’. How can I achieve that. Any help will be appreciated. Below is the code in…
lizet
  • 101
  • 6
1
vote
1 answer

How to build node-addon-api insulated from OS?

I have backend server with nodejs and deployed on heroku. Problem is that I need to use some fortran-based program with dll file (both 64-bit and 32-bit exists, and used 64-bit). To handle them all, I wrote some C++ code(node-addon-api). C++ with…
lee
  • 185
  • 2
  • 8
1
vote
1 answer

Async await in native module

I'm learning how to use node-addon-api and now I'm stuck on async/await management. I cannot understand how to handle the case where a native function receive an object which has an async function. Javascript: const addon =…
Marco Stramezzi
  • 2,143
  • 4
  • 17
  • 37
1
vote
2 answers

Node C++ Module Shared Library

I am trying to create a Node C++ module for the purpose of interfacing with the Steam api. The library file is ./steam/lib/linux64/libsteam_api.so, and header files are in ./steam. I have created a small regular C++ file for testing, which…
Daniel Herr
  • 19,083
  • 6
  • 44
  • 61
1
vote
0 answers

How to provide static C library functions with node-gyp?

I try to compile node_module via node-gyp and node-addon-api. Compilation has no errors, but I can not expose functions from static library. (As same as final node file is smaller than static library abc.a) binding.gyp { "targets": [ { …
Jiri Kral
  • 161
  • 4
0
votes
0 answers

Native Node Modules in Next.js Server Actions

When try to load a compiled native NODE-Addon I got this error: Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See…
eliasbauer
  • 11
  • 2
0
votes
0 answers

how can napi_instanceof be used to determine if an object is an instance of String?

I've written a node-addon using the Node API and want to handle both strings and String objects. It's easy enough to use napi_typeof to find out the type, but a String object is a napi_object, not a napi_string. How can I determine that the object…
bmacnaughton
  • 4,950
  • 3
  • 27
  • 36
0
votes
1 answer

How to include the same library in different linux distros with node-gyp

I'm trying to build my project on linux but I need to use two shared libraries (SDL2 and SDL2 image), the problem is that the path to the libraries depends on the distro. For example: on Ubuntu the libraries are saved in /usr/lib/x86_64-linux-gnu/…
0
votes
1 answer

Why is Napi::ThreadSafeFunction with ObjectWrap blocking the event loop from exiting?

I've found that using ThreadSafeFunction in an ObjectWrap class blocks the event loop from exiting even after the program has finished. As soon as I remove the functions which use ThreadSafeFunction (onScanStart and onScanStop), it exits correctly.…
Alex Shaw
  • 163
  • 1
  • 7
0
votes
0 answers

How can I reference a C++ variable to a Node.js class property using node-addon-api?

I'm working with node-addon-api. My code: class Cronjob : public Napi::ObjectWrap { private: Napi::Value wait(const Napi::CallbackInfo& info); Napi::Value time; public: static Napi::Object Init(Napi::Env env, Napi::Object…
1 2 3
8 9