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

Embedded Node execute .node file

I've built an embedded instance of Node using the Embed_Test example from the Node repository. Using this instance, I am trying to execute some C++ code. I have a generated .node and .dll, and I have webpack'd my Javascript file. When I run, node…
Acorn
  • 1,147
  • 12
  • 27
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
0 answers

reactjs / webpack error can't resolve napi module

I made a simple c++ n-api module which works when started with node but fails to load in reactjs / webpack const addon = require('./build/Release/module'); Module not found: Error: Can't resolve The path to module is correct. I'm using…
Reneb
  • 121
  • 2
  • 9
1
vote
1 answer

Nodejs 12 + N-api version conflict

I'm trying to use the bcrypt-package inside a vue-electron project, but there is an N-api version issue when I try to run it: Uncaught Error: The N-API version of this Node instance is 1. This module supports N-API version(s) 3. This Node instance…
borissjr
  • 71
  • 6
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 check a napi_value of type napi_number is an integer or decimal by using node.js N-API function,

How to check a given napi_value of type napi_number is an integer or decimal (a number with fractional value) by using node.js native N-API function . Look like there is no isInt() or isDouble() equivalent function in N-API (we don’t want to use V8…
Satyan
  • 1,346
  • 8
  • 15
1
vote
1 answer

Prebuild native addon dependencies (for node and electron)

I'm trying to use a native addon (Node Sentinel File Watcher -a.k.a. NSFW-) in a node application and also in an electron application. Using the same native addon with both (node and electron) doesn't work, so I have to rebuild the addon using…
caraie
  • 1,094
  • 7
  • 18
1
vote
0 answers

How to find out what module is missing with a C++ node addon

I am wondering if there's a way to get Node to provide a more useful message about which module I might be missing in a C++ n-api node addon. Here's the error: PS C:\Users\digit\Desktop\workspace\addons\endec> node .\index.js…
Suhail Doshi
  • 716
  • 1
  • 10
  • 23
0
votes
1 answer

How can i make a request to electron from my backend ( in NAPI )

So i am working with electron and i have a NAPI file where i have my backend code. On my interface, when i click on a certain button, a function is triggered and it calls the function from NAPI ( electron is the bridge between NAPI and my javascript…
alx
  • 1
0
votes
1 answer

How to catch exceptions/errors in addon.cc(using Nan)

Using Nan in addon.cc to invoke OpenSSL layer methods for decryption/signing/verification from NodeJS. When trying to hit the methods again and again in OpenSSL from NodeJS - getting decryption/verification errors - if these errors are hit for…
0
votes
1 answer

Write/Read files from C++ node addon

Having a simple C++ class that uses fstream to write/read binary files Controller.h: #pragma once #include #include #include #include #include using namespace std; template class…
Jesus Jimenez
  • 351
  • 1
  • 3
  • 13
0
votes
1 answer

Store function reference to call later from native module in N-API

I have a simple native Node.js addon that uses N-API. It exports two functions, set_callback and call_callback: set_callback takes a function parameter and assigns it to a global variable js_callback call_callback calls the js_callback using…
user7401478
  • 1,372
  • 1
  • 8
  • 25
0
votes
1 answer

How to handle wstring with NodeJS's N-API?

Does the NodeJS N-API have any concept or support for C++ wstring? I can't find entries for something like Napi::WString The documentation makes no mention of a WString. But wstring is commonly used on Windows APIs. I'm curious how it's typically…
Shane Gannon
  • 6,770
  • 7
  • 41
  • 64
0
votes
1 answer

node js application is crashing in uv_try_write while using N-API C++ addon on SIGPIPE. how can I handle/prevent the issue?

I am facing an issue where node application crashes when OS sends SIGPIPE. I am using N-API C++ addon for sending/receiving message to socket using Function Callbacks. is there any way to find the root cause or handle the same so that app does not…