Skip to content

node-api-headersv1.9.0

Updated

NodeJS API for writing modules in C++

#Usage

node-api-headers provides CMake targets:

find_package(unofficial-node-api-headers CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::node-api-headers::node-api-headers)

Add this to your CMakeLists.txt to build a Node.js addon:

add_library(addon SHARED main.cpp ...)
set_target_properties(addon PROPERTIES OUTPUT_NAME "my-addon" PREFIX "" SUFFIX ".node")

find_package(unofficial-node-api-headers CONFIG REQUIRED)
target_link_libraries(addon PRIVATE unofficial::node-api-headers::node-api-headers)

You will be able to load your addon in JavaScript code:

const addon = require("/path/to/addon/my-addon.node");

Make sure that your Node.js OS/architecture matches vcpkg triplet you use.

Also, make sure to register a module in your C/C++ code like official example does:
https://github.com/nodejs/node-addon-examples/blob/main/1_hello_world/napi/hello.c

This port doesn't have specific functionality for publishing npm packages.

See https://nodejs.org/api/n-api.html

#Supported Platforms

(windows & !arm & !uwp) | linux | osx

  • linux
  • osx
  • windows-x64
  • windows-x86
  • uwp
  • windows-arm64

#Features

No features defined.

#Dependencies

No dependencies.

#Host Dependencies

No transitive dependencies.

#Host Tool For

No ports use this.

#Contributors

  • Leonid Pospelov's avatarLeonid Pospelov
  • Ali Saki's avatarAli Saki
  • Long Nguyen's avatarLong Nguyen
  • SunBlack's avatarSunBlack
  • Weihang Ding's avatarWeihang Ding
  • toge's avatartoge

#Changelog

  • b5e593a[node-api-headers] Fix include path [vcpkg-ci-node-addon-api] New ci port (#52651)
  • 0e18fb3[node-api-headers] update to 1.9.0 (#51941)
  • bbd94c7[node-api-headers] Update to 1.8.0 (#51018)
  • a7be2ff[node-api-headers] Update to 1.6.0 (#48499)
  • d16cc7e[node-api-headers + node-addon-api] Update version + support mingw-w64 (#44802)
  • a784648[node-api-headers/node-addon-api] update node-api-headers to 1.1.0, and update node-addon-api to 7.0.0 (#35658)
  • 7c4f51f[node-api-headers] add usage (#31186)
  • 1a21cbb[node-api-headers] Update to 1.0.0 (#31019)
  • e4c66a5[node-api-headers] add missing compile definitions (#30903)
  • 78c1f5b[node-api] rework port, rename to node-api-headers, apply upstream's versioning (#29743)