napi-headers

June 18, 2019 ยท View on GitHub

ver Maintenance MIT dep size Known Vulnerabilities

npm CLI to download Node.js N-API headers and/or node-addon-api headers (for C++).

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm install napi-headers -g
# or
$ npx napi-headers

Usage example

When installed globally the nodehead (or napihead) executable will be exposed in your terminal.

$ nodehead -c -o ./include

API

napi-headers can be used as an API as well.

const headers = require("napi-headers");

headers.napi(process.cwd()).catch(console.error)

napi(dest: string, version?: string): void

Download N-API headers at the given destination. Version must be a valid Node.js release version (take a look here).

nodeAddonApi(dest: string, version?: string): void

Download Node-addon-api headers at the given destination. Version must be a valid node-addon-api package version.

Arguments

argumentshortcutdescriptiondefault value
--napi-nDownload Node.js N-API Headersfalse
--cpp-cDownload node-addon-api Headersfalse
--output-oOuput directory for headersprocess.cwd()/include

When --cpp is requested, --napi is ignored because node-addon-api already include Node.js N-API headers.

Note: when output is undefined, the include directory will be created automatically !

Download a given version of Node.js N-API headers

If you want to download headers for a specific version of Node.js, just write:

$ nodehead -n v11.0.0

Download a given version of Node-addon-api package

If you want to download a given version of node-addon-api (for headers), just write:

$ nodehead -c 1.6.0

License

MIT