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
Fixes grammar, removes extra lines and spaces, etc. Also removes a few
references to `node-waf`, which was removed ~6 years ago now. Happy to
add back if people still need that information.
PR-URL: #1498
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
`node-gyp` is a cross-platform command-line tool written in Node.js for compiling
6
-
native addon modules for Node.js. It bundles the [gyp](https://gyp.gsrc.io)
4
+
native addon modules for Node.js. It bundles the [gyp](https://gyp.gsrc.io)
7
5
project used by the Chromium team and takes away the pain of dealing with the
8
-
various differences in build platforms. It is the replacement to the `node-waf`
9
-
program which is removed for node `v0.8`. If you have a native addon for node that
10
-
still has a `wscript` file, then you should definitely add a `binding.gyp` file
11
-
to support the latest versions of node.
6
+
various differences in build platforms.
12
7
13
-
Multiple target versions of node are supported (i.e. `0.8`, ..., `4`, `5`, `6`,
14
-
etc.), regardless of what version of node is actually installed on your system
8
+
Multiple target versions of Node.js are supported (i.e. `0.8`, ..., `4`, `5`, `6`,
9
+
etc.), regardless of what version of Node.js is actually installed on your system
15
10
(`node-gyp` downloads the necessary development files or headers for the target version).
16
11
17
12
## Features
18
13
19
14
* Easy to use, consistent interface
20
15
* Same commands to build your module on every platform
21
-
* Supports multiple target versions of Node
16
+
* Supports multiple target versions of Node.js
22
17
23
-
24
-
Installation
25
-
------------
18
+
## Installation
26
19
27
20
You can install with `npm`:
28
21
@@ -80,16 +73,15 @@ version `node-gyp` uses by setting the '--python' variable:
80
73
$ node-gyp --python /path/to/python2.7
81
74
```
82
75
83
-
If `node-gyp` is called by way of `npm`*and* you have multiple versions of
76
+
If `node-gyp` is called by way of `npm`,*and* you have multiple versions of
84
77
Python installed, then you can set `npm`'s 'python' config key to the appropriate
85
78
value:
86
79
87
80
```bash
88
81
$ npm config set python /path/to/executable/python2.7
89
82
```
90
83
91
-
How to Use
92
-
----------
84
+
## How to Use
93
85
94
86
To compile your native addon, first go to its root directory:
95
87
@@ -110,33 +102,30 @@ needs to be added (not needed when run by npm as configured above):
110
102
$ node-gyp configure --msvs_version=2015
111
103
```
112
104
113
-
__Note__: The `configure` step looks for the`binding.gyp` file in the current
114
-
directory to process. See below for instructions on creating the`binding.gyp` file.
105
+
__Note__: The `configure` step looks for a`binding.gyp` file in the current
106
+
directory to process. See below for instructions on creating a`binding.gyp` file.
115
107
116
108
Now you will have either a `Makefile` (on Unix platforms) or a `vcxproj` file
117
-
(on Windows) in the `build/` directory. Next invoke the `build` command:
109
+
(on Windows) in the `build/` directory. Next, invoke the `build` command:
118
110
119
111
```bash
120
112
$ node-gyp build
121
113
```
122
114
123
115
Now you have your compiled `.node` bindings file! The compiled bindings end up
124
-
in `build/Debug/` or `build/Release/`, depending on the build mode. At this point
125
-
you can require the `.node` file with Node and run your tests!
116
+
in `build/Debug/` or `build/Release/`, depending on the build mode. At this point,
117
+
you can require the `.node` file with Node.js and run your tests!
126
118
127
119
__Note:__ To create a _Debug_ build of the bindings file, pass the `--debug` (or
128
-
`-d`) switch when running either the `configure`, `build` or `rebuild` command.
129
-
120
+
`-d`) switch when running either the `configure`, `build` or `rebuild` commands.
130
121
131
-
The "binding.gyp" file
132
-
----------------------
122
+
## The `binding.gyp` file
133
123
134
-
Previously when node had `node-waf` you had to write a `wscript` file. The
135
-
replacement for that is the `binding.gyp` file, which describes the configuration
136
-
to build your module in a JSON-like format. This file gets placed in the root of
137
-
your package, alongside the `package.json` file.
124
+
A `binding.gyp` file describes the configuration to build your module, in a
125
+
JSON-like format. This file gets placed in the root of your package, alongside
126
+
`package.json`.
138
127
139
-
A barebones `gyp` file appropriate for building a node addon looks like:
128
+
A barebones `gyp` file appropriate for building a Node.js addon could look like:
140
129
141
130
```python
142
131
{
@@ -158,8 +147,7 @@ Some additional resources for addons and writing `gyp` files:
158
147
*[*"binding.gyp" files out in the wild* wiki page](https://github.com/nodejs/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild)
159
148
160
149
161
-
Commands
162
-
--------
150
+
## Commands
163
151
164
152
`node-gyp` responds to the following commands:
165
153
@@ -170,86 +158,74 @@ Commands
170
158
| `clean` | Removes the `build` directory if it exists
171
159
| `configure` | Generates project build files for the current platform
172
160
| `rebuild` | Runs `clean`, `configure` and `build` all in a row
173
-
| `install` | Installs node header files for the given version
174
-
| `list` | Lists the currently installed node header versions
175
-
| `remove` | Removes the node header files for the given version
161
+
| `install` | Installs Node.js header files for the given version
162
+
| `list` | Lists the currently installed Node.js header versions
163
+
| `remove` | Removes the Node.js header files for the given version
[compiler update for the Windows SDK 7.1]: https://www.microsoft.com/en-us/download/details.aspx?id=4422
190
+
| `--python=$path` | Set path to the Python 2 binary
191
+
| `--msvs_version=$version` | Set Visual Studio version (Windows only)
192
+
| `--solution=$solution` | Set Visual Studio Solution version (Windows only)
193
+
194
+
## Configuration
195
+
196
+
### Environment variables
197
+
198
+
Use the form `npm_config_OPTION_NAME` for any of the command options listed
199
+
above (dashes in option names should be replaced by underscores).
200
+
201
+
For example, to set `devdir` equal to `/tmp/.gyp`, you would:
202
+
203
+
Run this on Unix:
204
+
205
+
```bash
206
+
$ export npm_config_devdir=/tmp/.gyp
207
+
```
208
+
209
+
Or this on Windows:
210
+
211
+
```console
212
+
> set npm_config_devdir=c:\temp\.gyp
213
+
```
214
+
215
+
### `npm` configuration
216
+
217
+
Use the form `OPTION_NAME` for any of the command options listed above.
218
+
219
+
For example, to set `devdir` equal to `/tmp/.gyp`, you would run:
220
+
221
+
```bash
222
+
$ npm config set [--global] devdir /tmp/.gyp
223
+
```
224
+
225
+
**Note:** Configuration set via `npm` will only be used when `node-gyp`
226
+
is run via `npm`, not when `node-gyp` is run directly.
227
+
228
+
## License
229
+
230
+
`node-gyp` is available under the MIT license. See the [LICENSE
0 commit comments