Skip to content

Commit 1fa6e6f

Browse files
Cong Liurogerwang
authored andcommitted
[doc] refactored doc for building native modules
Simplified the instructions of building native modules by dividing into LTS and non-LTS releases. Updated link and filename to `win_delay_load_hook.cc` and fixed nwjs#5396
1 parent cab64fa commit 1fa6e6f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/For Users/Advanced/Use Native Node Modules.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33

44
[TOC]
55

6-
`npm` tool provided by Node.js builds the native modules, i.e. [C/C++ Addons](https://nodejs.org/api/addons.html), at the time of installation.
6+
## For LTS Releases
77

8-
In 0.14.x LTS release, native modules built by node-gyp or npm in upstream can be supported.
8+
If you are using LTS release, native modules installed by `npm` can be supported after hacking as below:
99

10-
In Linux and OSX you can just load the native module directly. In windows you'll need to replace the file
11-
%APPDATA%\npm\node_modules\node-gyp\src\win_delay_load_hook.c with the one at https://github.com/nwjs/nw.js/blob/nw13/tools/win_delay_load_hook.c
10+
* On Linux and Mac, no hacking is required.
11+
* On Windows, you need to replace the file
12+
`<npm-path>\node_modules\node-gyp\src\win_delay_load_hook.cc` with the one at https://github.com/nwjs/nw.js/blob/nw18/tools/win_delay_load_hook.cc before installing modules with node-gyp or npm.
1213

13-
Before 0.13.0, the V8 version and Node API in NW.js is different from official Node.js. To use native Node.js modules with NW.js, you have to rebuild the modules with one of following tools. Starting from 0.15.0, rebuild with the following tools is also needed due to [ABI change in v8](https://github.com/nwjs/nw.js/issues/5025)
14+
## For non-LTS Releases
1415

15-
## nw-gyp
16+
If you are using non-LTS release, you have to rebuild the modules with one of following tools due to [ABI differences in V8](https://github.com/nwjs/nw.js/issues/5025).
17+
18+
### nw-gyp
1619

1720
[`nw-gyp`](https://github.com/nwjs/nw-gyp) is a hack on `node-gyp` to support NW.js specific headers and libraries.
1821

@@ -26,7 +29,7 @@ nw-gyp rebuild --target=0.13.0 --arch=x64
2629

2730
See https://github.com/nwjs/nw-gyp for more details.
2831

29-
## node-pre-gyp
32+
### node-pre-gyp
3033

3134
Some packages uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp), which supports building for both Node.js and NW.js by using either `node-gyp` or `nw-gyp`.
3235

@@ -39,7 +42,7 @@ node-pre-gyp build --runtime=node-webkit --target=0.13.0 --target_arch=x64
3942

4043
See https://github.com/mapbox/node-pre-gyp for more details.
4144

42-
## Known Issues
45+
### Known Issues
4346

4447
So far, you have to rebuild **each native module** with tools above including thoses are indirectly depended modules. Since `binding.gyp` is required for building native modules, you can easily locate all native modules by finding `binding.gyp` file.
4548

0 commit comments

Comments
 (0)