Questions tagged [n-api]

N-API (pronounced N as in the letter, followed by API) is an API for building native Addons. It is independent from the underlying JavaScript runtime (for example, V8) and is maintained as part of Node.js itself. This API will be Application Binary Interface (ABI) stable across versions of Node.js. It is intended to insulate Addons from changes in the underlying JavaScript engine and allow modules compiled for one major version to run on later major versions of Node.js without recompilation.

For more information refer to the official reference: https://nodejs.org/api/n-api.html

61 questions
0
votes
1 answer

Resource sharing using N-API?

I was wondering if it was possible to use the N-API to give a workerthread access to an object that a different workerthread has created. Although I do not require concurrent access, I currently transfer data by serializing and deserializing it.…
asdasdasdadw
  • 21
  • 1
  • 2
0
votes
1 answer

NodeJS Addon build error C3861: '_alloca': identifier not found

When trying to build a simple node addon with boost,the compiler fails with this error absolute\path\to\boost_1_76_0\boost_1_76_0\boost\asio\detail\impl\socket_ops.ipp(2481,34): error C3861: '_alloca': identifier not found…
eskawl
  • 587
  • 1
  • 4
  • 17
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
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

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

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

Why can't N-API find some bindings when using napi_property_descriptor array?

I have the following code... // robot_node.c #include #include #include "robot_node.h" #include "robot.h" napi_value node_forward(napi_env env, napi_callback_info info){ napi_value result; napi_status status; int…
Jackie
  • 21,969
  • 32
  • 147
  • 289
0
votes
1 answer

engine.node: undefined symbol: _ZTV6Config

I have written my first Node.JS N-Api addon but it crashes with log: internal/modules/cjs/loader.js:718 return process.dlopen(module, path.toNamespacedPath(filename)); ^ Error: /home/d/Projects/engine/build/Release/engine.node:…
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
0
votes
1 answer

error: ‘Object’ does not name a type - trying to learn NodeJS N-API

Having trouble finding a sufficiently precise answer, basically my compiler (GCC std=c++11) does recognise the type "Object". Yes, I am fairly new to ++ Tried changing command line options, tried Googling for an exact solution. If anyone spots any…
jatos
  • 31
  • 4
0
votes
1 answer

Problem with my Native C++ Addon in Electron in Mac

I am writing code to load c++ dynamic library from electron. When trying it in Mac I get the following error: dyld: Symbol not found: __ZN15FcDrive2Library13InitDrive2LibEv Referenced from:…
Nikhil
  • 181
  • 1
  • 15
0
votes
2 answers

How to use InstanceMethod() to wrap a method returning an Object?

Working on creating an add-on that will return an Object to the node environment. Basing my work on Atul Anand's introduction to N-API in C++, the methods of the class object are wrapped in InstanceMethod() to expose them; but that function wants a…
Mike C
  • 1,224
  • 10
  • 26
0
votes
1 answer

N-API C++ addon causing Electron GUI to block

I have an N-API C++ addon that I would like to use with an Electron GUI. Currently the C++ addon has a simple function that sleeps for 10 seconds and then performs a computation of 8*2, and returns the value to the Javascript code. The Javascript…
Raees Rajwani
  • 487
  • 5
  • 18
-1
votes
1 answer

No native build was found for platform=darwin arch=arm64 runtime=electron abi=103

I'm currently trying to use the following package in my electron Application: https://github.com/SnosMe/uiohook-napi But whatever I do I always get the above mentioned error in the console. I access the package in a preload file via import {…
myfoxit
  • 69
  • 2
  • 8
-1
votes
1 answer

What should be the correct way to send to the front-end the napi_values I receive from the native-addon?

I am trying to communicate this native addon with the front-end. It consists of a prime number generator, when it is executed it writes to the console, I want it to send them via Sockets to the browser console. With this code I invoke the addon and…