# node-gyp-build

> Build tool and bindings loader for [`node-gyp`](https://www.npmjs.com/package/node-gyp) that supports prebuilds.

```
npm install node-gyp-build
```

[![Test](https://github.com/prebuild/node-gyp-build/actions/workflows/test.yml/badge.svg)](https://github.com/prebuild/node-gyp-build/actions/workflows/test.yml)

Use together with [`prebuildify`](https://github.com/prebuild/prebuildify) to easily support prebuilds for your native modules.

## Usage

> **Note.** Prebuild names have changed in [`prebuildify@3`](https://github.com/prebuild/prebuildify) and `node-gyp-build@4`. Please see the documentation below.

`node-gyp-build` works similar to [`node-gyp build`](https://www.npmjs.com/package/node-gyp) except that it will check if a build or prebuild is present before rebuilding your project.

It's main intended use is as an npm install script and bindings loader for native modules that bundle prebuilds using [`prebuildify`](https://github.com/prebuild/prebuildify).

First add `node-gyp-build` as an install script to your native project

```js
{
  ...
  "scripts": {
    "install": "node-gyp-build"
  }
}
```

Then in your `index.js`, instead of using the [`bindings`](https://www.npmjs.com/package/bindings) module use `node-gyp-build` to load your binding.

```js
var binding = require('node-gyp-build')(__dirname)
```

If you do these two things and bundle prebuilds with [`prebuildify`](https://github.com/prebuild/prebuildify) your native module will work for most platforms without having to compile on install time AND will work in both node and electron without the need to recompile between usage.

Users can override `node-gyp-build` and force compiling by doing `npm install --build-from-source`.

Prebuilds will be attempted loaded from `MODULE_PATH/prebuilds/...` and then next `EXEC_PATH/prebuilds/...` (the latter allowing use with `zeit/pkg`)

## Supported prebuild names

If so desired you can bundle more specific flavors, for example `musl` builds to support Alpine, or targeting a numbered ARM architecture version.

These prebuilds can be bundled in addition to generic prebuilds; `node-gyp-build` will try to find the most specific flavor first. Prebuild filenames are composed of *tags*. The runtime tag takes precedence, as does an `abi` tag over `napi`. For more details on tags, please see [`prebuildify`](https://github.com/prebuild/prebuildify).

Values for the `libc` and `armv` tags are auto-detected but can be overridden through the `LIBC` and `ARM_VERSION` environment variables, respectively.

## License

MIT


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://civictech-ou.gitbook.io/nova-docs/nova-sdk-js/examples/node_modules/node-gyp-build.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
