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
@@ -69,16 +62,15 @@ version `node-gyp` uses by setting the '--python' variable:
69
62
$ node-gyp --python /path/to/python2.7
70
63
```
71
64
72
-
If `node-gyp` is called by way of `npm`*and* you have multiple versions of
65
+
If `node-gyp` is called by way of `npm`,*and* you have multiple versions of
73
66
Python installed, then you can set `npm`'s 'python' config key to the appropriate
74
67
value:
75
68
76
69
```bash
77
70
$ npm config set python /path/to/executable/python2.7
78
71
```
79
72
80
-
How to Use
81
-
----------
73
+
## How to Use
82
74
83
75
To compile your native addon, first go to its root directory:
84
76
@@ -99,33 +91,30 @@ needs to be added (not needed when run by npm as configured above):
99
91
$ node-gyp configure --msvs_version=2015
100
92
```
101
93
102
-
__Note__: The `configure` step looks for the`binding.gyp` file in the current
103
-
directory to process. See below for instructions on creating the`binding.gyp` file.
94
+
__Note__: The `configure` step looks for a`binding.gyp` file in the current
95
+
directory to process. See below for instructions on creating a`binding.gyp` file.
104
96
105
97
Now you will have either a `Makefile` (on Unix platforms) or a `vcxproj` file
106
-
(on Windows) in the `build/` directory. Next invoke the `build` command:
98
+
(on Windows) in the `build/` directory. Next, invoke the `build` command:
107
99
108
100
```bash
109
101
$ node-gyp build
110
102
```
111
103
112
104
Now you have your compiled `.node` bindings file! The compiled bindings end up
113
-
in `build/Debug/` or `build/Release/`, depending on the build mode. At this point
114
-
you can require the `.node` file with Node and run your tests!
105
+
in `build/Debug/` or `build/Release/`, depending on the build mode. At this point,
106
+
you can require the `.node` file with Node.js and run your tests!
115
107
116
108
__Note:__ To create a _Debug_ build of the bindings file, pass the `--debug` (or
117
-
`-d`) switch when running either the `configure`, `build` or `rebuild` command.
118
-
109
+
`-d`) switch when running either the `configure`, `build` or `rebuild` commands.
119
110
120
-
The "binding.gyp" file
121
-
----------------------
111
+
## The `binding.gyp` file
122
112
123
-
Previously when node had `node-waf` you had to write a `wscript` file. The
124
-
replacement for that is the `binding.gyp` file, which describes the configuration
125
-
to build your module in a JSON-like format. This file gets placed in the root of
126
-
your package, alongside the `package.json` file.
113
+
A `binding.gyp` file describes the configuration to build your module, in a
114
+
JSON-like format. This file gets placed in the root of your package, alongside
115
+
`package.json`.
127
116
128
-
A barebones `gyp` file appropriate for building a node addon looks like:
117
+
A barebones `gyp` file appropriate for building a Node.js addon could look like:
129
118
130
119
```python
131
120
{
@@ -147,8 +136,7 @@ Some additional resources for addons and writing `gyp` files:
147
136
*[*"binding.gyp" files out in the wild* wiki page](https://github.com/nodejs/node-gyp/wiki/%22binding.gyp%22-files-out-in-the-wild)
148
137
149
138
150
-
Commands
151
-
--------
139
+
## Commands
152
140
153
141
`node-gyp` responds to the following commands:
154
142
@@ -159,86 +147,74 @@ Commands
159
147
| `clean` | Removes the `build` directory if it exists
160
148
| `configure` | Generates project build files for the current platform
161
149
| `rebuild` | Runs `clean`, `configure` and `build` all in a row
162
-
| `install` | Installs node header files for the given version
163
-
| `list` | Lists the currently installed node header versions
164
-
| `remove` | Removes the node header files for the given version
150
+
| `install` | Installs Node.js header files for the given version
151
+
| `list` | Lists the currently installed Node.js header versions
152
+
| `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
179
+
| `--python=$path` | Set path to the Python 2 binary
180
+
| `--msvs_version=$version` | Set Visual Studio version (Windows only)
181
+
| `--solution=$solution` | Set Visual Studio Solution version (Windows only)
182
+
183
+
## Configuration
184
+
185
+
### Environment variables
186
+
187
+
Use the form `npm_config_OPTION_NAME` for any of the command options listed
188
+
above (dashes in option names should be replaced by underscores).
189
+
190
+
For example, to set `devdir` equal to `/tmp/.gyp`, you would:
191
+
192
+
Run this on Unix:
193
+
194
+
```bash
195
+
$ export npm_config_devdir=/tmp/.gyp
196
+
```
197
+
198
+
Or this on Windows:
199
+
200
+
```console
201
+
> set npm_config_devdir=c:\temp\.gyp
202
+
```
203
+
204
+
### `npm` configuration
205
+
206
+
Use the form `OPTION_NAME` for any of the command options listed above.
207
+
208
+
For example, to set `devdir` equal to `/tmp/.gyp`, you would run:
209
+
210
+
```bash
211
+
$ npm config set [--global] devdir /tmp/.gyp
212
+
```
213
+
214
+
**Note:** Configuration set via `npm` will only be used when `node-gyp`
215
+
is run via `npm`, not when `node-gyp` is run directly.
216
+
217
+
## License
218
+
219
+
`node-gyp` is available under the MIT license. See the [LICENSE
0 commit comments