3
3
` node-gyp ` is a cross-platform command-line tool written in Node.js for
4
4
compiling native addon modules for Node.js. It contains a fork of the
5
5
[ gyp] ( https://gyp.gsrc.io ) project that was previously used by the Chromium
6
- team and takes away the pain of dealing with the various differences in build
7
- platforms.
6
+ team, extended to support the development of Node.js native addons.
8
7
9
8
Note that ` node-gyp ` is _ not_ used to build Node.js itself.
10
9
@@ -14,23 +13,18 @@ etc.), regardless of what version of Node.js is actually installed on your syste
14
13
15
14
## Features
16
15
17
- * Easy to use, consistent interface
18
- * Same commands to build your module on every platform
19
- * Supports multiple target versions of Node.js
16
+ * The same build commands work on any of the supported platforms
17
+ * Supports the targetting of different versions of Node.js
20
18
21
19
## Installation
22
20
23
- You can install with ` npm ` :
21
+ You can install ` node-gyp ` using ` npm ` :
24
22
25
23
``` bash
26
24
$ npm install -g node-gyp
27
25
```
28
26
29
- You will also need to install:
30
-
31
- NOTE: node-gyp is compatible with Python v2.7, v3.5, v3.6, or v3.7. If the
32
- Python to use is not explicitly configured (see "Configuring Python Dependency"
33
- below) it will attempt to find a compatible Python executable.
27
+ Depending on your operating system, you will need to install:
34
28
35
29
### On Unix
36
30
@@ -67,27 +61,30 @@ Install tools and configuration manually:
67
61
68
62
### Configuring Python Dependency
69
63
70
- If you have multiple Python versions installed, you can identify which Python
71
- version ` node-gyp ` uses by setting the ` --python ` variable:
64
+ ` node-gyp ` requires that you have installed a compatible version of Python, one of: v2.7, v3.5, v3.6,
65
+ or v3.7. If you have multiple Python versions installed, you can identify which Python
66
+ version ` node-gyp ` should use in one of the following ways:
67
+
68
+ 1 . by setting the ` --python ` command-line option, e.g.:
72
69
73
70
``` bash
74
71
$ node-gyp < command> --python /path/to/executable/python
75
72
```
76
73
77
- If ` node-gyp ` is called by way of ` npm ` , * and* you have multiple versions of
74
+ 2 . If ` node-gyp ` is called by way of ` npm ` , * and* you have multiple versions of
78
75
Python installed, then you can set ` npm ` 's 'python' config key to the appropriate
79
76
value:
80
77
81
78
``` bash
82
79
$ npm config set python /path/to/executable/python
83
80
```
84
81
85
- If the ` PYTHON ` environment variable is set to the path of a Python executable,
86
- it will be used if it is a compatible Python .
82
+ 3 . If the ` PYTHON ` environment variable is set to the path of a Python executable,
83
+ then that version will be used, if it is a compatible version .
87
84
88
- If the ` NODE_GYP_FORCE_PYTHON ` environment variable is set to the path of a
85
+ 4 . If the ` NODE_GYP_FORCE_PYTHON ` environment variable is set to the path of a
89
86
Python executable, it will be used instead of any of the other configured or
90
- builtin Python search paths. If its not a compatible Python , no further
87
+ builtin Python search paths. If it's not a compatible version , no further
91
88
searching will be done.
92
89
93
90
## How to Use
@@ -147,15 +144,16 @@ A barebones `gyp` file appropriate for building a Node.js addon could look like:
147
144
}
148
145
```
149
146
150
- Some additional resources for addons and writing ` gyp ` files:
147
+ ## Further reading
148
+
149
+ Some additional resources for Node.js native addons and writing ` gyp ` configuration files:
151
150
152
151
* [ "Going Native" a nodeschool.io tutorial] ( http://nodeschool.io/#goingnative )
153
152
* [ "Hello World" node addon example] ( https://github.com/nodejs/node/tree/master/test/addons/hello-world )
154
153
* [ gyp user documentation] ( https://gyp.gsrc.io/docs/UserDocumentation.md )
155
154
* [ gyp input format reference] ( https://gyp.gsrc.io/docs/InputFormatReference.md )
156
155
* [ * "binding.gyp" files out in the wild* wiki page] ( https://github.com/nodejs/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild )
157
156
158
-
159
157
## Commands
160
158
161
159
` node-gyp ` responds to the following commands:
0 commit comments