# @sigma-db/napi

> A utility to setup an environment for development of native Node.js modules.

Latest version **0.4.2** (published 2019-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sigma-db/napi
pnpm add @sigma-db/napi
yarn add @sigma-db/napi
bun add @sigma-db/napi
```

Provides the command `napi`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2019-12-14 |
| First published | 2019-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 71.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Luis Wiegandt |
| Maintainers | dlw93 |
| Keywords | N-API, native |

## Links

- npm: https://www.npmjs.com/package/@sigma-db/napi
- Repository: https://dev.azure.com/dlw/sigmaDB/_git/napi-cli
- npm.io page: https://npm.io/package/@sigma-db/napi

## Recent versions

- 0.4.2 (latest) — 2019-12-14
- 0.4.1 — 2019-12-14
- 0.4.0 — 2019-12-13
- 0.3.29 — 2019-12-13
- 0.3.28 — 2019-12-12
- 0.3.27 — 2019-12-12
- 0.3.26 — 2019-12-12
- 0.3.25 — 2019-12-12
- 0.3.24 — 2019-12-08
- 0.3.23 — 2019-12-08
- 0.3.22 — 2019-12-08
- 0.3.21 — 2019-12-08
- 0.3.20 — 2019-12-08
- 0.3.19 — 2019-12-05
- 0.3.18 — 2019-12-05
- … 22 more at https://npm.io/package/@sigma-db/napi/versions

## README

# N-API CLI

[![NPM](https://img.shields.io/npm/v/@sigma-db/napi)](https://www.npmjs.com/package/@sigma-db/napi)
![node version](https://img.shields.io/node/v/@sigma-db/napi)

This project eases the process of setting up an environment for developing [native Node.js modules](https://nodejs.org/dist/latest-v13.x/docs/api/n-api.html) by fetching the correct architecture- and OS-specific header and library files as well as preparing the `CMakeLists.txt` acxcordingly.

## Prerequisites

Currently, this tool requires `cmake` and `ninja` to be in your `PATH`, as well as a working C/C++ toolchain.

* On **Windows**, you can use the [Visual Studio Build Tools](https://download.visualstudio.microsoft.com/download/pr/5446351f-19f5-4b09-98c6-a4bfacc732d7/7da4388648c92544c97407c6f052fd6bc0317db407cadab9fdcb328a34d3e317/vs_BuildTools.exe) which includes all required tools. In that case, make sure that you use the appropriate *Tools Command Prompt for Visual Studio*
* On **Linux** and other **UNIX**-like environments, make sure to have `cmake`, `ninja`, `clang`/`gcc` and `ld` available in your `PATH`.

## Installation

Run `npm i -g @sigma-db/napi` to install the `napi` CLI globally.

## Usage

Assume we want to create and build a project named `native`.

1. **create** the project and change into its directory by running `napi new native && cd native`.

2. **initialise** the project by running `napi init` from within the project directory to automatically download the appropriate header and static library files.

3. **build** the project by running `napi build` from within the project directory.

4. **test** that requiring your native module actually works by running `napi test` from within the project directory. You should see an output like `A project named "native" is growing here.`

5. **clean** any files generated during the build by running `napi clean` from within the project directory. Note that doing this will make `CMake` run again on the next build, considerably increasing the build time of the next build.

### Changing the Node.js version

If you happen to change to version of Node.js, you will also require new header and static library files. In that case, run `napi clean all`, which will delete any previously downloaded header and library files, as well as any built files.

## Disclaimer

The current code was written in a single 16h session and might need quite some refactoring and more user-friendly error-handling — I'd love to see people contributing.

---
_Source: https://npm.io/package/@sigma-db/napi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
