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
0
votes
2 answers

Node Add-on Nan::NewBuffer Causes Memory Leak

I have a c++ node add on that uses the Nan library. I have a function that needs to return a buffer. The simplest version of it is as follows (code edited as per comments): NAN_METHOD(Test) { char * retVal = (char*)malloc(100 * sizeof(char)); …
cershif
  • 154
  • 1
  • 13
0
votes
1 answer

How to read file from NAPI (node-addon) interface and write to a different file using nodejs filestream

I am trying to read a file in the NAPI application and call the callback function to write it to the writestream in the nodejs application. exmaple_Class.cpp void readFromTransientFile(const Napi::CallbackInfo &info) { Napi::Env env =…
0
votes
1 answer

Getting a String Argument From Node Add On

I am trying to pass a string to a C++ add on in Node.js. I am using the Nan library as seems to be recommended. For the equivalent task with a number I do the following: NAN_METHOD(funcName) { if (!info[0]->IsUint32()) { …
cershif
  • 154
  • 1
  • 13
0
votes
1 answer

Reading N-API object into C++ primitive

I've created a simple N-API module starting from the ObjectWrap boilerplate of generator-napi-module, and successfully passed data (an array containing objects with string, number and boolean properties) to JS. However, I'm unable to parse the…
NickT
  • 116
  • 1
  • 8
0
votes
1 answer

N-API pass argument within require statement

I am creating an n-api module, is it possible to pass an argument when the require is called? js wrapper const NativeAPI = new (require('./../build/Release/mymodule.node')).Hello(3); // how do i access this argument 3 inside TestClass::Init() cpp…
t348575
  • 674
  • 8
  • 19
0
votes
1 answer

Installed package has out-of-date header files

The node-addon-api package is installed and I have been compiling using those header files just fine. But I went to take advantage of a feature and my addon would not compile; the symbol was missing from the headers. After comparing to the header…
Mike C
  • 1,224
  • 10
  • 26
0
votes
1 answer

Storing a JS Callback to be called later in Node C++ Addon

I'm creating a Node C++ addon for macOS, so I'm using Objective-C mixed with C++ and the Node Addon API. I want to provide a function for Node JS, that receives a callback to be called later when an Obj-C observer is called. This is how I tried to…
Emad Omar
  • 729
  • 9
  • 23
0
votes
0 answers

Unable to get new values from external module

I have a date module that returns current date that is set in system: function getDateFormatAndISODate() { const dates = require('./resources/getSystemDate').getSystemDate(); return dates; } module.exports.getDateFormatAndISODate =…
kittu
  • 6,662
  • 21
  • 91
  • 185
0
votes
1 answer

NAPI addon throwing "undefined symbol: omp_get_max_threads" from .node file

This seems like a weird error. I tried debugging the native code line by line and this error seems to happen out of nowhere, like at the end of a function call. It's seem to be caused by certain parts of code in the native library I'm using, because…
Nay Min
  • 85
  • 10
0
votes
1 answer

Add node NAPI Function as callback to native library

Is it possible to add javascript function as callback to a native library accepting callbacks through NAPI? Here's an example addon code I have so far. Napi::Function *jsCallback; void RegisterReadyEvent(const Napi::CallbackInfo &info) { …
0
votes
1 answer

C++ addon won't compile with node 12

I'm trying to compile this older npm package on Windows using the latest version of node and it's throwing some C compiler errors that I just don't understand. Any help understanding these errors and how to address them would be greatly…
0
votes
0 answers

C++ Nodejs addons Database connection

I am learning NODEJS addons building I was able to build a simple application but now I have a problem in connecting to the database using addons and passing query data to NODEJS Can anyone suggest me what should I do?? I am developing my…
0
votes
1 answer

Promise invocation using node-addon-api throws error or gives no output

Code: https://github.com/t348575/blockchain-api-testing/tree/master Blocks are added using genesis(). A thread watches the worker queue, and sends blocks to be computed and added to the chain. Order needs to be preserved, which is why i have a…
t348575
  • 674
  • 8
  • 19
0
votes
2 answers

How to save an asynchronous callback for later using node-addon-api / napi

I'm using AsyncWorkerto run an asynchronous task. The problem is that i have numerous tasks to be run, one after another, and the order is important. To keep order i'm using a queuing technique to make sure the AsyncWorkerobjects are created in the…
t348575
  • 674
  • 8
  • 19
0
votes
1 answer

calling Napi::ThreadSafeFunction::Release() results in ELIFECYCLE 3221225477 (STATUS_ACCESS_VIOLATION)

A mention in the title I have some weird thread issues. Basically I am wrapping PS2000 Api with node-addon-api like in the linked example. As those api callbacks need "C" like functions, I trampolined those with something like: CLASSNAME…
Estradiaz
  • 3,483
  • 1
  • 11
  • 22
1 2 3
8
9