1# Building Node.js with Ninja
2
3The purpose of this guide is to show how to build Node.js using [Ninja][], as
4doing so can be significantly quicker than using `make`. Please see
5[Ninja's site][Ninja] for installation instructions (unix only).
6
7To build Node.js with ninja, there are 3 steps that must be taken:
8
91. Configure the project's OS-based build rules via `./configure --ninja`.
102. Run `ninja -C out/Release` to produce a compiled release binary.
113. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`.
12
13When running `ninja -C out/Release` you will see output similar to the following
14if the build has succeeded:
15
16```txt
17ninja: Entering directory `out/Release`
18[4/4] LINK node, POSTBUILDS
19```
20
21The bottom line will change while building, showing the progress as
22`[finished/total]` build steps. This is useful output that `make` does not
23produce and is one of the benefits of using Ninja. Also, Ninja will likely
24compile much faster than even `make -j4` (or
25`-j<number of processor threads on your machine>`).
26
27## Considerations
28
29Ninja builds vary slightly from `make` builds. If you wish to run `make test`
30after, `make` will likely still need to rebuild some amount of Node.js.
31
32As such, if you wish to run the tests, it can be helpful to invoke the test
33runner directly, like so:
34`tools/test.py --mode=release message parallel sequential -J`
35
36## Alias
37
38`alias nnode='./configure --ninja && ninja -C out/Release && ln -fs
39out/Release/node node'`
40
41## Producing a debug build
42
43The above alias can be modified slightly to produce a debug build, rather than a
44release build as shown below:
45`alias nnodedebug='./configure --ninja && ninja -C out/Debug && ln -fs
46out/Debug/node node_g'`
47
48
49[Ninja]: https://ninja-build.org/
50