You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-50Lines changed: 53 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,12 @@
9
9
10
10
## Overview
11
11
12
-
To enable binary installs `node-pre-gyp` you set up `npm` to call `node-pre-gyp` to install a module which overrides the default `npm` behavior of calling `node-gyp` to build from source.
13
-
14
-
`node-pre-gyp` stands between `npm` and `node-gyp`. It offers two main things:
12
+
`node-pre-gyp` stands between [npm](https://github.com/npm/npm) and [node-gyp](https://github.com/Tootallnate/node-gyp). It offers two main things:
15
13
16
14
- A command line tool called `node-pre-gyp` that can install your package from a binary or publish it.
17
15
- Javascript code that can be required to dynamically find your module: `require('node-pre-gyp').find`
18
16
19
-
For a hello world example of a Node.js C++ modules packaged with `node-pre-gyp` see <https://github.com/springmeyer/node-addon-example>.
17
+
For a hello world example of a Node.js C++ module packaged with `node-pre-gyp` see <https://github.com/springmeyer/node-addon-example>.
20
18
21
19
## Modules using `node-pre-gyp`:
22
20
@@ -28,43 +26,75 @@ For a hello world example of a Node.js C++ modules packaged with `node-pre-gyp`
28
26
29
27
For more examples see the [test apps](test/).
30
28
29
+
## Depends
30
+
31
+
- Node.js 0.10.x or 0.8.x
32
+
33
+
## Install
34
+
35
+
`node-pre-gyp` is designed to be installed as a local dependency of your Node.js C++ addon and accessed like:
36
+
37
+
./node_modules/.bin/node-pre-gyp --help
38
+
39
+
But you can also install it globally:
40
+
41
+
npm install node-pre-gyp -g
42
+
31
43
## Usage
32
44
33
-
**1) Add node-pre-gyp as a bundled dependency in `package.json`**
45
+
### Commands
46
+
47
+
View all possible commands:
48
+
49
+
node-pre-gyp --help
50
+
51
+
- clean - Removes the entire folder containing the compiled .node module
52
+
- install - Attempts to install pre-built binary for module
53
+
- reinstall - Runs "clean" and "install" at once
54
+
- build - Attempts to compile the module by dispatching to node-gyp or nw-gyp
55
+
- rebuild - Runs "clean" and "build" at once
56
+
- package - Packs binary into tarball
57
+
- testpackage - Tests that the staged package is valid
58
+
- publish - Publishes pre-built binary
59
+
- unpublish - Unpublishes pre-built binary
60
+
- info - Fetches info on published binaries
61
+
62
+
You can also chain commands:
63
+
64
+
node-pre-gyp clean build unpublish publish info
65
+
66
+
### Configuring your module to use node-pre-gyp
67
+
68
+
**1) Add new entries to your `package.json`**
69
+
70
+
We need to:
71
+
72
+
- Add node-pre-gyp as a bundled dependency
73
+
- Add a custom `install` script
74
+
- Add a `binary` object
75
+
76
+
This looks like:
34
77
35
78
```js
36
79
"dependencies": {
37
80
"node-pre-gyp":"0.5.x"
38
81
},
39
82
"bundledDependencies":["node-pre-gyp"],
40
-
```
41
-
42
-
43
-
**2) Add a custom `install` script to `package.json`**
#### The `binary` object has three required properties
64
94
65
95
##### module_name
66
96
67
-
The name of your native node module.This must match the name passed to [the NODE_MODULE macro](http://nodejs.org/api/addons.html#addons_hello_world) and should not include the `.node` extension.
97
+
The name of your native node module.This must match the name passed to [the NODE_MODULE macro](http://nodejs.org/api/addons.html#addons_hello_world) and should not include the `.node` extension.
68
98
69
99
##### module_path
70
100
@@ -74,7 +104,7 @@ The location your native module is placed after a build. This should be an empty
74
104
75
105
A url to the remote location where you've published tarball binaries (must be `https` not `http`)
76
106
77
-
Optional properties:
107
+
#### The `binary` object has two optional properties
78
108
79
109
##### remote_path
80
110
@@ -292,33 +322,6 @@ Or you could automatically detect if the git branch is a tag:
292
322
Remember this publishing is not the same as `npm publish`. We're just talking about the
293
323
binary module here and not your entire npm package. To automate the publishing of your entire package to npm on travis see http://about.travis-ci.org/docs/user/deployment/npm/
294
324
295
-
### Commands
296
-
297
-
View all possible commands:
298
-
299
-
node-pre-gyp --help
300
-
301
-
302
-
#### List published binaries
303
-
304
-
node-pre-gyp info
305
-
306
-
#### Unpublish binaries
307
-
308
-
node-pre-gyp unpublish
309
-
310
-
#### Clean install and build artifacts
311
-
312
-
node-pre-gyp clean
313
-
314
-
#### Clean and install
315
-
316
-
node-pre-gyp reinstall # runs "clean" and "install"
0 commit comments