11cb0ef41Sopenharmony_ci# Building Node.js with Ninja 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciThe purpose of this guide is to show how to build Node.js using [Ninja][], as 41cb0ef41Sopenharmony_cidoing so can be significantly quicker than using `make`. Please see 51cb0ef41Sopenharmony_ci[Ninja's site][Ninja] for installation instructions (Unix only). 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci[Ninja][] is supported in the Makefile. Run `./configure --ninja` to configure 81cb0ef41Sopenharmony_cithe project to run the regular `make` commands with Ninja. 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciFor example, `make` will execute `ninja -C out/Release` internally 111cb0ef41Sopenharmony_cito produce a compiled release binary, It will also execute 121cb0ef41Sopenharmony_ci`ln -fs out/Release/node node`, so that you can execute `./node` at 131cb0ef41Sopenharmony_cithe project's root. 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciWhen running `make`, you will see output similar to the following 161cb0ef41Sopenharmony_ciif the build has succeeded: 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci```console 191cb0ef41Sopenharmony_cininja: Entering directory `out/Release` 201cb0ef41Sopenharmony_ci[4/4] LINK node, POSTBUILDS 211cb0ef41Sopenharmony_ci``` 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciThe bottom line will change while building, showing the progress as 241cb0ef41Sopenharmony_ci`[finished/total]` build steps. This is useful output that `make` does not 251cb0ef41Sopenharmony_ciproduce and is one of the benefits of using Ninja. When using Ninja, builds 261cb0ef41Sopenharmony_ciare always run in parallel, based by default on the number of CPUs your 271cb0ef41Sopenharmony_cisystem has. You can use the `-j` parameter to override this behavior, 281cb0ef41Sopenharmony_ciwhich is equivalent to the `-j` parameter in the regular `make`: 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci```bash 311cb0ef41Sopenharmony_cimake -j4 # With this flag, Ninja will limit itself to 4 parallel jobs, 321cb0ef41Sopenharmony_ci # regardless of the number of cores on the current machine. 331cb0ef41Sopenharmony_ci``` 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci## Producing a debug build 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ciTo create a debug build rather than a release build: 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci```bash 401cb0ef41Sopenharmony_ci./configure --ninja --debug && make 411cb0ef41Sopenharmony_ci``` 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci## Customizing `ninja` path 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ciOn some systems (such as RHEL7 and below), the Ninja binary might be installed 461cb0ef41Sopenharmony_ciwith a different name. For these systems use the `NINJA` env var: 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci```bash 491cb0ef41Sopenharmony_ci./configure --ninja && NINJA="ninja-build" make 501cb0ef41Sopenharmony_ci``` 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci[Ninja]: https://ninja-build.org/ 53