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
7[Ninja][] is supported in the Makefile. Run `./configure --ninja` to configure
8the project to run the regular `make` commands with Ninja.
9
10For example, `make` will execute `ninja -C out/Release` internally
11to produce a compiled release binary, It will also execute
12`ln -fs out/Release/node node`, so that you can execute `./node` at
13the project's root.
14
15When running `make`, you will see output similar to the following
16if the build has succeeded:
17
18```console
19ninja: Entering directory `out/Release`
20[4/4] LINK node, POSTBUILDS
21```
22
23The bottom line will change while building, showing the progress as
24`[finished/total]` build steps. This is useful output that `make` does not
25produce and is one of the benefits of using Ninja. When using Ninja, builds
26are always run in parallel, based by default on the number of CPUs your
27system has. You can use the `-j` parameter to override this behavior,
28which is equivalent to the `-j` parameter in the regular `make`:
29
30```bash
31make -j4 # With this flag, Ninja will limit itself to 4 parallel jobs,
32         # regardless of the number of cores on the current machine.
33```
34
35## Producing a debug build
36
37To create a debug build rather than a release build:
38
39```bash
40./configure --ninja --debug && make
41```
42
43## Customizing `ninja` path
44
45On some systems (such as RHEL7 and below), the Ninja binary might be installed
46with a different name. For these systems use the `NINJA` env var:
47
48```bash
49./configure --ninja && NINJA="ninja-build" make
50```
51
52[Ninja]: https://ninja-build.org/
53