node-addon-api is the C++ wrapper for N-API, the ABI stable library to build addons for Node.js.
Questions tagged [node-addon-api]
126 questions
0
votes
1 answer
How to free up a buffer in apache after execution of CGI-script with Nodejs?
I am using Apache CGI-Script with Nodejs to develop dynamic web page content
Here I am using Node addon C++ (sample.node) as CGI-script. That uses node environment with the help of Addhandler and Action option provided by apache.
In my configuration…

Jeyaprakash
- 151
- 3
- 11
0
votes
1 answer
Is there an "undefined behavior" problem with some APIs in "node-addon-api"?
In , there are some overloads declaration for the static method Accessor in the class PropertyDescriptor.
One of such overloads declaration is here:
template
static PropertyDescriptor Accessor(Napi::Env env,
…

manuell
- 7,528
- 5
- 31
- 58
0
votes
1 answer
Wrap native (c++) method inside a Promise
I have a synchronous C++ Node.js addon function that does an heavy operation:
Napi::Object SyncHeavyFunction(const Napi::CallbackInfo& info) {
std::this_thread::sleep_for(std::chrono::seconds(50));
...
return env.Null();
}
I'm trying to…

Luckk
- 518
- 3
- 7
0
votes
1 answer
How to get a JavaScript number as a string using Node-API
I'm building a Node.js addon using Node-API.
The logic has been simplified as below,
Use pass js array into the addon and get some filtered array as the output.
Inside the addon, the algorithm will skip any empty strings and false values.
Below is…

0xdw
- 3,755
- 2
- 25
- 40
0
votes
1 answer
Use stdlib and rand with Node native module (node-gyp)
This is just an example of the problem.
Let's say I have utils.cc
#include "../headers/utils/utils.h"
double sum()
{
double result = 1 + 1;
return result;
}
double multisum(int n)
{
double result = 0;
for (int i = 0; i < n; i++)
…

EuberDeveloper
- 874
- 1
- 14
- 38
0
votes
1 answer
Which is best way to write graphql api for flat file management?
Here I discuss the implementation of GraphQL in my Project data structure.
In my project, I am using flat files(text files) fixed-width format for DB management. I want to integrate API developments with that. flat files queried from CPP program. In…

Jeyaprakash
- 151
- 3
- 11
0
votes
2 answers
Linking a shared library with node-addon-api
I'm building a Node.js wrapper for a C shared library using node-gyp and node-addon-api. It works! But as the library was built from Golang code, I have different builds for different architectures -- the module can't compile the C library from the…

tobynicholas
- 1
- 1
0
votes
1 answer
Global shared data between different instances of a Node.js native addon?
I'm looking to create a native addon with Node-API (more specifically with the C++ wrapper module node-addon-api).
I need to have global read-only data that will be loaded once and will be shared between different instances of the addon (e.g. when…

Windom Earle
- 648
- 3
- 7
- 21
0
votes
0 answers
How to construct Napi::CallbackInfo object manually by c++?
I have written a number of addon functions, and I make sure they are available.
Now I want to test these functions by unit test, written by google-test, therefore I need to manually call these functions in c++. Therefore, I need to pass the…

Robert
- 31
- 2
0
votes
1 answer
node-addon-api how to pass int pointer back and forth between JS and C/C++
I have the following backend functions:
// foo.c
void cStart(pid_t* pid)
{
*pid = getpid();
// event-loop keep running until receive SIGINT signal
}
void cStop(pid_t* pid)
{
kill(*pid, SIGINT);
}
// addon.cpp
#include "addon.h"
#include…

Monica.J
- 27
- 1
- 6
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
0 answers
undefined reference to `napi_create_function', compiled using cmake
I'm trying to compile a machine learning code written in c++ and connecting it to NodeJS using n-api, I have written the NAPI function in one of the files, and defined additional dependencies in CMake.
Installed
'node-addon-api':…
0
votes
0 answers
Do Node-Addon-Api needs deconstractor?
I'm using Node-Addon-Api to create addons in NodeJS. every 30 second there is a call to a addon's function, every time the function is called 4 double arrays, with highest array size of 2400 values, are been created.
I'm experiencing memory…
0
votes
1 answer
node js callback from native C++ code is throwing errors
I am trying to implement event listeners. Node js will subscribe to the events (using C++ function). When the event occurs, C++ should inform node js.
JS code:
pal.subscribeEvent("ONSTATECHANGE", function(a) { console.log("Event received for…

kadina
- 5,042
- 4
- 42
- 83
0
votes
1 answer
nodejs napi How to manually create a CallbackInfo type data
I want to call some existing functions, but the function requires the CallbackInfo parameter, how do I initialize a CallbackInfo
Value b(const CallbackInfo& info)
{
...
}
Value a(const CallbackInfo& info)
{
CallbackInfo newInfo =…

januw a
- 2,056
- 5
- 18
- 39