1 | # node-gyp-build
|
2 |
|
3 | Build tool and bindings loader for node-gyp that supports prebuilds.
|
4 |
|
5 | ```
|
6 | npm install node-gyp-build
|
7 | ```
|
8 |
|
9 | Use together with [prebuildify](https://github.com/mafintosh/prebuildify) to easily support prebuilds for your native modules.
|
10 |
|
11 | ## Usage
|
12 |
|
13 | `node-gyp-build` works similar to `node-gyp build` except that it will check if a build or prebuild is present before rebuilding your project.
|
14 |
|
15 | 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/mafintosh/prebuildify).
|
16 |
|
17 | First add `node-gyp-build` as an install script to your native project
|
18 |
|
19 | ``` js
|
20 | {
|
21 | ...
|
22 | "scripts": {
|
23 | "install": "node-gyp-build"
|
24 | }
|
25 | }
|
26 | ```
|
27 |
|
28 | Then in your `index.js`, instead of using the [bindings module](https://www.npmjs.com/package/bindings) use `node-gyp-build` to load your binding.
|
29 |
|
30 | ``` js
|
31 | var binding = require('node-gyp-build')(__dirname)
|
32 | ```
|
33 |
|
34 | If you do these two things and bundle prebuilds [prebuildify](https://github.com/mafintosh/prebuildify) your native module will work for most platforms
|
35 | without having to compile on install time AND will work in both node and electron without the need to recompile between usage.
|
36 |
|
37 | ## License
|
38 |
|
39 | MIT
|