• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Building Node.js
2
3Depending on what platform or features you need, the build process may
4differ. After you've built a binary, running the
5test suite to confirm that the binary works as intended is a good next step.
6
7If you can reproduce a test failure, search for it in the
8[Node.js issue tracker](https://github.com/nodejs/node/issues) or
9file a new issue.
10
11## Table of contents
12
13* [Supported platforms](#supported-platforms)
14  * [Input](#input)
15  * [Strategy](#strategy)
16  * [Platform list](#platform-list)
17  * [Supported toolchains](#supported-toolchains)
18  * [Official binary platforms and toolchains](#official-binary-platforms-and-toolchains)
19    * [OpenSSL asm support](#openssl-asm-support)
20  * [Previous versions of this document](#previous-versions-of-this-document)
21* [Building Node.js on supported platforms](#building-nodejs-on-supported-platforms)
22  * [Note about Python 2 and Python 3](#note-about-python-2-and-python-3)
23  * [Unix and macOS](#unix-and-macos)
24    * [Unix prerequisites](#unix-prerequisites)
25    * [macOS prerequisites](#macos-prerequisites)
26    * [Building Node.js](#building-nodejs-1)
27    * [Installing Node.js](#installing-nodejs)
28    * [Running Tests](#running-tests)
29    * [Running Coverage](#running-coverage)
30    * [Building the documentation](#building-the-documentation)
31    * [Building a debug build](#building-a-debug-build)
32    * [Building an ASAN build](#building-an-asan-build)
33    * [Speeding up frequent rebuilds when developing](#speeding-up-frequent-rebuilds-when-developing)
34    * [Troubleshooting Unix and macOS builds](#troubleshooting-unix-and-macos-builds)
35  * [Windows](#windows)
36    * [Prerequisites](#prerequisites)
37      * [Option 1: Manual install](#option-1-manual-install)
38      * [Option 2: Automated install with Boxstarter](#option-2-automated-install-with-boxstarter)
39    * [Building Node.js](#building-nodejs-2)
40  * [Android/Android-based devices (e.g. Firefox OS)](#androidandroid-based-devices-eg-firefox-os)
41* [`Intl` (ECMA-402) support](#intl-ecma-402-support)
42  * [Build with full ICU support (all locales supported by ICU)](#build-with-full-icu-support-all-locales-supported-by-icu)
43    * [Unix/macOS](#unixmacos)
44    * [Windows](#windows-1)
45  * [Trimmed: `small-icu` (English only) support](#trimmed-small-icu-english-only-support)
46    * [Unix/macOS](#unixmacos-1)
47    * [Windows](#windows-2)
48  * [Building without Intl support](#building-without-intl-support)
49    * [Unix/macOS](#unixmacos-2)
50    * [Windows](#windows-3)
51  * [Use existing installed ICU (Unix/macOS only)](#use-existing-installed-icu-unixmacos-only)
52  * [Build with a specific ICU](#build-with-a-specific-icu)
53    * [Unix/macOS](#unixmacos-3)
54    * [Windows](#windows-4)
55* [Building Node.js with FIPS-compliant OpenSSL](#building-nodejs-with-fips-compliant-openssl)
56* [Building Node.js with external core modules](#building-nodejs-with-external-core-modules)
57  * [Unix/macOS](#unixmacos-4)
58  * [Windows](#windows-5)
59* [Note for downstream distributors of Node.js](#note-for-downstream-distributors-of-nodejs)
60
61## Supported platforms
62
63This list of supported platforms is current as of the branch/release to
64which it belongs.
65
66### Input
67
68Node.js relies on V8 and libuv. We adopt a subset of their supported platforms.
69
70### Strategy
71
72There are three support tiers:
73
74* **Tier 1**: These platforms represent the majority of Node.js users. The
75  Node.js Build Working Group maintains infrastructure for full test coverage.
76  Test failures on tier 1 platforms will block releases.
77* **Tier 2**: These platforms represent smaller segments of the Node.js user
78  base. The Node.js Build Working Group maintains infrastructure for full test
79  coverage. Test failures on tier 2 platforms will block releases.
80  Infrastructure issues may delay the release of binaries for these platforms.
81* **Experimental**: May not compile or test suite may not pass. The core team
82  does not create releases for these platforms. Test failures on experimental
83  platforms do not block releases. Contributions to improve support for these
84  platforms are welcome.
85
86Platforms may move between tiers between major release lines. The table below
87will reflect those changes.
88
89### Platform list
90
91Node.js compilation/execution support depends on operating system, architecture,
92and libc version. The table below lists the support tier for each supported
93combination. A list of [supported compile toolchains](#supported-toolchains) is
94also supplied for tier 1 platforms.
95
96**For production applications, run Node.js on supported platforms only.**
97
98Node.js does not support a platform version if a vendor has expired support
99for it. In other words, Node.js does not support running on End-of-Life (EoL)
100platforms. This is true regardless of entries in the table below.
101
102| Operating System | Architectures    | Versions                        | Support Type | Notes                             |
103| ---------------- | ---------------- | ------------------------------- | ------------ | --------------------------------- |
104| GNU/Linux        | x64              | kernel >= 3.10, glibc >= 2.17   | Tier 1       | e.g. Ubuntu 16.04 <sup>[1](#fn1)</sup>, Debian 9, EL 7 <sup>[2](#fn2)</sup> |
105| GNU/Linux        | x64              | kernel >= 3.10, musl >= 1.1.19  | Experimental | e.g. Alpine 3.8                   |
106| GNU/Linux        | x86              | kernel >= 3.10, glibc >= 2.17   | Experimental | Downgraded as of Node.js 10       |
107| GNU/Linux        | arm64            | kernel >= 4.5, glibc >= 2.17    | Tier 1       | e.g. Ubuntu 16.04, Debian 9, EL 7 <sup>[3](#fn3)</sup> |
108| GNU/Linux        | armv7            | kernel >= 4.14, glibc >= 2.24   | Tier 1       | e.g. Ubuntu 18.04, Debian 9       |
109| GNU/Linux        | armv6            | kernel >= 4.14, glibc >= 2.24   | Experimental | Downgraded as of Node.js 12       |
110| GNU/Linux        | ppc64le >=power8 | kernel >= 3.10.0, glibc >= 2.17 | Tier 2       | e.g. Ubuntu 16.04 <sup>[1](#fn1)</sup>, EL 7  <sup>[2](#fn2)</sup> |
111| GNU/Linux        | s390x            | kernel >= 3.10.0, glibc >= 2.17 | Tier 2       | e.g. EL 7 <sup>[2](#fn2)</sup>    |
112| Windows          | x64, x86 (WoW64) | >= Windows 8.1/2012 R2          | Tier 1       | <sup>[4](#fn4),[5](#fn5)</sup>    |
113| Windows          | x86 (native)     | >= Windows 8.1/2012 R2          | Tier 1 (running) / Experimental (compiling) <sup>[6](#fn6)</sup> | |
114| Windows          | x64, x86         | Windows Server 2012 (not R2)    | Experimental |                                   |
115| Windows          | arm64            | >= Windows 10                   | Tier 2 (compiling) / Experimental (running) |    |
116| macOS            | x64              | >= 10.11                        | Tier 1       |                                   |
117| macOS            | arm64            | >= 11                           | Experimental |                                   |
118| SmartOS          | x64              | >= 18                           | Tier 2       |                                   |
119| AIX              | ppc64be >=power7 | >= 7.2 TL02                     | Tier 2       |                                   |
120| FreeBSD          | x64              | >= 11                           | Experimental | Downgraded as of Node.js 12  <sup>[7](#fn7)</sup>     |
121
122<em id="fn1">1</em>: GCC 6 is not provided on the base platform. Users will
123  need the
124  [Toolchain test builds PPA](https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test?field.series_filter=xenial)
125  or similar to source a newer compiler.
126
127<em id="fn2">2</em>: GCC 6 is not provided on the base platform. Users will
128  need the
129  [devtoolset-6](https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/)
130  or later to source a newer compiler.
131
132<em id="fn3">3</em>: Older kernel versions may work for ARM64. However the
133  Node.js test infrastructure only tests >= 4.5.
134
135<em id="fn4">4</em>: On Windows, running Node.js in Windows terminal emulators
136  like `mintty` requires the usage of [winpty](https://github.com/rprichard/winpty)
137  for the tty channels to work (e.g. `winpty node.exe script.js`).
138  In "Git bash" if you call the node shell alias (`node` without the `.exe`
139  extension), `winpty` is used automatically.
140
141<em id="fn5">5</em>: The Windows Subsystem for Linux (WSL) is not
142  supported, but the GNU/Linux build process and binaries should work. The
143  community will only address issues that reproduce on native GNU/Linux
144  systems. Issues that only reproduce on WSL should be reported in the
145  [WSL issue tracker](https://github.com/Microsoft/WSL/issues). Running the
146  Windows binary (`node.exe`) in WSL is not recommended. It will not work
147  without workarounds such as stdio redirection.
148
149<em id="fn6">6</em>: Running Node.js on x86 Windows should work and binaries
150are provided. However, tests in our infrastructure only run on WoW64.
151Furthermore, compiling on x86 Windows is Experimental and
152may not be possible.
153
154<em id="fn7">7</em>: The default FreeBSD 12.0 compiler is Clang 6.0.1, but
155FreeBSD 12.1 upgrades to 8.0.1. Other Clang/LLVM versions are available
156via the system's package manager, including Clang 9.0.
157
158### Supported toolchains
159
160Depending on the host platform, the selection of toolchains may vary.
161
162| Operating System | Compiler Versions                                              |
163| ---------------- | -------------------------------------------------------------- |
164| Linux            | GCC >= 6.3                                                     |
165| Windows          | Visual Studio >= 2017 with the Windows 10 SDK on a 64-bit host |
166| macOS            | Xcode >= 10 (Apple LLVM >= 10)                                 |
167
168### Official binary platforms and toolchains
169
170Binaries at <https://nodejs.org/download/release/> are produced on:
171
172| Binary package        | Platform and Toolchain                                                                                        |
173| --------------------- | ------------------------------------------------------------------------------------------------------------- |
174| aix-ppc64             | AIX 7.1 TL05 on PPC64BE with GCC 6                                                                            |
175| darwin-x64 (and .pkg) | macOS 10.15, Xcode Command Line Tools 11 with -mmacosx-version-min=10.13                                      |
176| linux-arm64           | CentOS 7 with devtoolset-8 / GCC 8 <sup>[8](#fn8)</sup>                                                       |
177| linux-armv7l          | Cross-compiled on Ubuntu 18.04 x64 with [custom GCC toolchain](https://github.com/rvagg/rpi-newer-crosstools) |
178| linux-ppc64le         | CentOS 7 with devtoolset-8 / GCC 8 <sup>[8](#fn8)</sup>                                                       |
179| linux-s390x           | RHEL 7 with devtoolset-8 / GCC 8 <sup>[8](#fn8)</sup>                                                         |
180| linux-x64             | CentOS 7 with devtoolset-8 / GCC 8 <sup>[8](#fn8)</sup>                                                       |
181| win-x64 and win-x86   | Windows 2012 R2 (x64) with Visual Studio 2019                                                                 |
182
183<em id="fn8">8</em>: The Enterprise Linux devtoolset-8 allows us to compile
184binaries with GCC 8 but linked to the glibc and libstdc++ versions of the host
185platforms (CentOS 7 / RHEL 7). Therefore, binaries produced on these systems
186are compatible with glibc >= 2.17 and libstdc++ >= 6.0.20 (`GLIBCXX_3.4.20`).
187These are available on distributions natively supporting GCC 4.9, such as
188Ubuntu 14.04 and Debian 8.
189
190#### OpenSSL asm support
191
192OpenSSL-1.1.1 requires the following assembler version for use of asm
193support on x86_64 and ia32.
194
195For use of AVX-512,
196
197* gas (GNU assembler) version 2.26 or higher
198* nasm version 2.11.8 or higher in Windows
199
200AVX-512 is disabled for Skylake-X by OpenSSL-1.1.1.
201
202For use of AVX2,
203
204* gas (GNU assembler) version 2.23 or higher
205* Xcode version 5.0 or higher
206* llvm version 3.3 or higher
207* nasm version 2.10 or higher in Windows
208
209Please refer to
210 <https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_ia32cap.html> for details.
211
212 If compiling without one of the above, use `configure` with the
213`--openssl-no-asm` flag. Otherwise, `configure` will fail.
214
215### Previous versions of this document
216
217Supported platforms and toolchains change with each major version of Node.js.
218This document is only valid for the current major version of Node.js.
219Consult previous versions of this document for older versions of Node.js:
220
221* [Node.js 14](https://github.com/nodejs/node/blob/v14.x/BUILDING.md)
222* [Node.js 12](https://github.com/nodejs/node/blob/v12.x/BUILDING.md)
223* [Node.js 10](https://github.com/nodejs/node/blob/v10.x/BUILDING.md)
224
225## Building Node.js on supported platforms
226
227### Note about Python 2 and Python 3
228
229The Node.js project supports both Python 3 and Python 2 for building.
230If both are installed Python 3 will be used. If only Python 2 is available
231it will be used instead. When possible we recommend that you build and
232test with Python 3.
233
234### Unix and macOS
235
236#### Unix prerequisites
237
238* `gcc` and `g++` >= 6.3 or newer, or
239* GNU Make 3.81 or newer
240* Python (see note above)
241  * Python 2.7
242  * Python 3.5, 3.6, 3.7, 3.8, 3.9 or 3.10 (see note above)
243
244Installation via Linux package manager can be achieved with:
245
246* Ubuntu, Debian: `sudo apt-get install python g++ make`
247* Fedora: `sudo dnf install python gcc-c++ make`
248* CentOS and RHEL: `sudo yum install python gcc-c++ make`
249* OpenSUSE: `sudo zypper install python gcc-c++ make`
250* Arch Linux, Manjaro: `sudo pacman -S python gcc make`
251
252FreeBSD and OpenBSD users may also need to install `libexecinfo`.
253
254#### macOS prerequisites
255
256* Xcode Command Line Tools >= 10 for macOS
257* Python (see note above)
258  * Python 2.7
259  * Python 3.6, 3.7, 3.8, 3.9, or 3.10 (see note above)
260
261macOS users can install the `Xcode Command Line Tools` by running
262`xcode-select --install`. Alternatively, if you already have the full Xcode
263installed, you can find them under the menu `Xcode -> Open Developer Tool ->
264More Developer Tools...`. This step will install `clang`, `clang++`, and
265`make`.
266
267#### Building Node.js
268
269If the path to your build directory contains a space, the build will likely
270fail.
271
272To build Node.js:
273
274```console
275$ ./configure
276$ make -j4
277```
278
279The `-j4` option will cause `make` to run 4 simultaneous compilation jobs which
280may reduce build time. For more information, see the
281[GNU Make Documentation](https://www.gnu.org/software/make/manual/html_node/Parallel.html).
282
283The above requires that `python` resolves to a supported version of
284Python. See [Prerequisites](#prerequisites).
285
286After building, setting up [firewall rules](tools/macos-firewall.sh) can avoid
287popups asking to accept incoming network connections when running tests.
288
289Running the following script on macOS will add the firewall rules for the
290executable `node` in the `out` directory and the symbolic `node` link in the
291project's root directory.
292
293```console
294$ sudo ./tools/macos-firewall.sh
295```
296
297#### Installing Node.js
298
299To install this version of Node.js into a system directory:
300
301```bash
302[sudo] make install
303```
304
305#### Running tests
306
307To verify the build:
308
309```console
310$ make test-only
311```
312
313At this point, you are ready to make code changes and re-run the tests.
314
315If you are running tests before submitting a pull request, the recommended
316command is:
317
318```console
319$ make -j4 test
320```
321
322`make -j4 test` does a full check on the codebase, including running linters and
323documentation tests.
324
325Make sure the linter does not report any issues and that all tests pass. Please
326do not submit patches that fail either check.
327
328If you want to run the linter without running tests, use
329`make lint`/`vcbuild lint`. It will lint JavaScript, C++, and Markdown files.
330
331If you are updating tests and want to run tests in a single test file
332(e.g. `test/parallel/test-stream2-transform.js`):
333
334```text
335$ python tools/test.py test/parallel/test-stream2-transform.js
336```
337
338You can execute the entire suite of tests for a given subsystem
339by providing the name of a subsystem:
340
341```text
342$ python tools/test.py -J --mode=release child-process
343```
344
345If you want to check the other options, please refer to the help by using
346the `--help` option:
347
348```text
349$ python tools/test.py --help
350```
351
352You can usually run tests directly with node:
353
354```text
355$ ./node ./test/parallel/test-stream2-transform.js
356```
357
358Remember to recompile with `make -j4` in between test runs if you change code in
359the `lib` or `src` directories.
360
361The tests attempt to detect support for IPv6 and exclude IPv6 tests if
362appropriate. If your main interface has IPv6 addresses, then your
363loopback interface must also have '::1' enabled. For some default installations
364on Ubuntu that does not seem to be the case. To enable '::1' on the
365loopback interface on Ubuntu:
366
367```bash
368sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0
369```
370
371You can use
372[node-code-ide-configs](https://github.com/nodejs/node-code-ide-configs)
373to run/debug tests, if your IDE configs are present.
374
375#### Running coverage
376
377It's good practice to ensure any code you add or change is covered by tests.
378You can do so by running the test suite with coverage enabled:
379
380```console
381$ ./configure --coverage
382$ make coverage
383```
384
385A detailed coverage report will be written to `coverage/index.html` for
386JavaScript coverage and to `coverage/cxxcoverage.html` for C++ coverage.
387
388If you only want to run the JavaScript tests then you do not need to run
389the first command (`./configure --coverage`). Run `make coverage-run-js`,
390to execute JavaScript tests independently of the C++ test suite:
391
392```text
393$ make coverage-run-js
394```
395
396If you are updating tests and want to collect coverage for a single test file
397(e.g. `test/parallel/test-stream2-transform.js`):
398
399```text
400$ make coverage-clean
401$ NODE_V8_COVERAGE=coverage/tmp python tools/test.py test/parallel/test-stream2-transform.js
402$ make coverage-report-js
403```
404
405You can collect coverage for the entire suite of tests for a given subsystem
406by providing the name of a subsystem:
407
408```text
409$ make coverage-clean
410$ NODE_V8_COVERAGE=coverage/tmp python tools/test.py -J --mode=release child-process
411$ make coverage-report-js
412```
413
414The `make coverage` command downloads some tools to the project root directory.
415To clean up after generating the coverage reports:
416
417```console
418$ make coverage-clean
419```
420
421#### Building the documentation
422
423To build the documentation:
424
425This will build Node.js first (if necessary) and then use it to build the docs:
426
427```bash
428make doc
429```
430
431If you have an existing Node.js build, you can build just the docs with:
432
433```bash
434NODE=/path/to/node make doc-only
435```
436
437To read the man page:
438
439```bash
440man doc/node.1
441```
442
443If you prefer to read the full documentation in a browser, run the following.
444
445```bash
446make docserve
447```
448
449This will spin up a static file server and provide a URL to where you may browse
450the documentation locally.
451
452If you're comfortable viewing the documentation using the program your operating
453system has associated with the default web browser, run the following.
454
455```bash
456make docopen
457```
458
459This will open a file URL to a one-page version of all the browsable HTML
460documents using the default browser.
461
462To test if Node.js was built correctly:
463
464```bash
465./node -e "console.log('Hello from Node.js ' + process.version)"
466```
467
468#### Building a debug build
469
470If you run into an issue where the information provided by the JS stack trace
471is not enough, or if you suspect the error happens outside of the JS VM, you
472can try to build a debug enabled binary:
473
474```console
475$ ./configure --debug
476$ make -j4
477```
478
479`make` with `./configure --debug` generates two binaries, the regular release
480one in `out/Release/node` and a debug binary in `out/Debug/node`, only the
481release version is actually installed when you run `make install`.
482
483To use the debug build with all the normal dependencies overwrite the release
484version in the install directory:
485
486``` console
487$ make install PREFIX=/opt/node-debug/
488$ cp -a -f out/Debug/node /opt/node-debug/node
489```
490
491When using the debug binary, core dumps will be generated in case of crashes.
492These core dumps are useful for debugging when provided with the
493corresponding original debug binary and system information.
494
495Reading the core dump requires `gdb` built on the same platform the core dump
496was captured on (i.e. 64-bit `gdb` for `node` built on a 64-bit system, Linux
497`gdb` for `node` built on Linux) otherwise you will get errors like
498`not in executable format: File format not recognized`.
499
500Example of generating a backtrace from the core dump:
501
502``` console
503$ gdb /opt/node-debug/node core.node.8.1535359906
504$ backtrace
505```
506
507#### Building an ASAN build
508
509[ASAN](https://github.com/google/sanitizers) can help detect various memory
510related bugs. ASAN builds are currently only supported on linux.
511If you want to check it on Windows or macOS or you want a consistent toolchain
512on Linux, you can try [Docker](https://www.docker.com/products/docker-desktop)
513 (using an image like `gengjiawen/node-build:2020-02-14`).
514
515The `--debug` is not necessary and will slow down build and testing, but it can
516show clear stacktrace if ASAN hits an issue.
517
518``` console
519$  ./configure --debug --enable-asan && make -j4
520$ make test-only
521```
522
523#### Speeding up frequent rebuilds when developing
524
525If you plan to frequently rebuild Node.js, especially if using several branches,
526installing `ccache` can help to greatly reduce build times. Set up with:
527```console
528$ sudo apt install ccache   # for Debian/Ubuntu, included in most Linux distros
529$ ccache -o cache_dir=<tmp_dir>
530$ ccache -o max_size=5.0G
531$ export CC="ccache gcc"    # add to your .profile
532$ export CXX="ccache g++"   # add to your .profile
533```
534This will allow for near-instantaneous rebuilds even when switching branches.
535
536When modifying only the JS layer in `lib`, it is possible to externally load it
537without modifying the executable:
538```console
539$ ./configure --node-builtin-modules-path $(pwd)
540```
541The resulting binary won't include any JS files and will try to load them from
542the specified directory. The JS debugger of Visual Studio Code supports this
543configuration since the November 2020 version and allows for setting
544breakpoints.
545
546#### Troubleshooting Unix and macOS builds
547
548Stale builds can sometimes result in `file not found` errors while building.
549This and some other problems can be resolved with `make distclean`. The
550`distclean` recipe aggressively removes build artifacts. You will need to
551build again (`make -j4`). Since all build artifacts have been removed, this
552rebuild may take a lot more time than previous builds. Additionally,
553`distclean` removes the file that stores the results of `./configure`. If you
554ran `./configure` with non-default options (such as `--debug`), you will need
555to run it again before invoking `make -j4`.
556
557### Windows
558
559#### Prerequisites
560
561##### Option 1: Manual install
562
563* [Python 3.8](https://www.python.org/downloads/)
564* The "Desktop development with C++" workload from
565  [Visual Studio 2017 or 2019](https://visualstudio.microsoft.com/downloads/) or
566  the "Visual C++ build tools" workload from the
567  [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019),
568  with the default optional components
569* Basic Unix tools required for some tests,
570  [Git for Windows](https://git-scm.com/download/win) includes Git Bash
571  and tools which can be included in the global `PATH`.
572* The [NetWide Assembler](https://www.nasm.us/), for OpenSSL assembler modules.
573  If not installed in the default location, it needs to be manually added
574  to `PATH`. A build with the `openssl-no-asm` option does not need this, nor
575  does a build targeting ARM64 Windows.
576
577Optional requirements to build the MSI installer package:
578
579* The [WiX Toolset v3.11](https://wixtoolset.org/releases/) and the
580  [Wix Toolset Visual Studio 2017 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension)
581  or the [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension).
582* The [WiX Toolset v3.14](https://wixtoolset.org/releases/) if
583  building for Windows 10 on ARM (ARM64)
584
585Optional requirements for compiling for Windows 10 on ARM (ARM64):
586
587* Visual Studio 15.9.0 or newer
588* Visual Studio optional components
589  * Visual C++ compilers and libraries for ARM64
590  * Visual C++ ATL for ARM64
591* Windows 10 SDK 10.0.17763.0 or newer
592
593##### Option 2: Automated install with Boxstarter
594
595A [Boxstarter](https://boxstarter.org/) script can be used for easy setup of
596Windows systems with all the required prerequisites for Node.js development.
597This script will install the following [Chocolatey](https://chocolatey.org/)
598packages:
599
600* [Git for Windows](https://chocolatey.org/packages/git) with the `git` and
601  Unix tools added to the `PATH`
602* [Python 3.x](https://chocolatey.org/packages/python) and
603  [legacy Python](https://chocolatey.org/packages/python2)
604* [Visual Studio 2019 Build Tools](https://chocolatey.org/packages/visualstudio2019buildtools)
605  with [Visual C++ workload](https://chocolatey.org/packages/visualstudio2017-workload-vctools)
606* [NetWide Assembler](https://chocolatey.org/packages/nasm)
607
608To install Node.js prerequisites using
609[Boxstarter WebLauncher](https://boxstarter.org/WebLauncher), open
610<https://boxstarter.org/package/nr/url?https://raw.githubusercontent.com/nodejs/node/HEAD/tools/bootstrap/windows_boxstarter>
611with Internet Explorer or Edge browser on the target machine.
612
613Alternatively, you can use PowerShell. Run those commands from an elevated
614PowerShell terminal:
615
616```powershell
617Set-ExecutionPolicy Unrestricted -Force
618iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1'))
619get-boxstarter -Force
620Install-BoxstarterPackage https://raw.githubusercontent.com/nodejs/node/HEAD/tools/bootstrap/windows_boxstarter -DisableReboots
621```
622
623The entire installation using Boxstarter will take up approximately 10 GB of
624disk space.
625
626#### Building Node.js
627
628If the path to your build directory contains a space or a non-ASCII character,
629the build will likely fail.
630
631```console
632> .\vcbuild
633```
634
635To run the tests:
636
637```console
638> .\vcbuild test
639```
640
641To test if Node.js was built correctly:
642
643```console
644> Release\node -e "console.log('Hello from Node.js', process.version)"
645```
646
647### Android/Android-based devices (e.g. Firefox OS)
648
649Android is not a supported platform. Patches to improve the Android build are
650welcome. There is no testing on Android in the current continuous integration
651environment. The participation of people dedicated and determined to improve
652Android building, testing, and support is encouraged.
653
654Be sure you have downloaded and extracted
655[Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) before in
656a folder. Then run:
657
658```console
659$ ./android-configure /path/to/your/android-ndk
660$ make
661```
662
663## `Intl` (ECMA-402) support
664
665[Intl](https://github.com/nodejs/node/blob/HEAD/doc/api/intl.md) support is
666enabled by default.
667
668### Build with full ICU support (all locales supported by ICU)
669
670This is the default option.
671
672#### Unix/macOS
673
674```console
675$ ./configure --with-intl=full-icu
676```
677
678#### Windows
679
680```console
681> .\vcbuild full-icu
682```
683
684### Trimmed: `small-icu` (English only) support
685
686 In this configuration, only English data is included, but
687the full `Intl` (ECMA-402) APIs.  It does not need to download
688any dependencies to function. You can add full data at runtime.
689
690#### Unix/macOS
691
692```console
693$ ./configure --with-intl=small-icu
694```
695
696#### Windows
697
698```console
699> .\vcbuild small-icu
700```
701
702### Building without Intl support
703
704The `Intl` object will not be available, nor some other APIs such as
705`String.normalize`.
706
707#### Unix/macOS
708
709```console
710$ ./configure --without-intl
711```
712
713#### Windows
714
715```console
716> .\vcbuild without-intl
717```
718
719### Use existing installed ICU (Unix/macOS only)
720
721```console
722$ pkg-config --modversion icu-i18n && ./configure --with-intl=system-icu
723```
724
725If you are cross-compiling, your `pkg-config` must be able to supply a path
726that works for both your host and target environments.
727
728### Build with a specific ICU
729
730You can find other ICU releases at
731[the ICU homepage](http://site.icu-project.org/download).
732Download the file named something like `icu4c-**##.#**-src.tgz` (or
733`.zip`).
734
735To check the minimum recommended ICU, run `./configure --help` and see
736the help for the `--with-icu-source` option. A warning will be printed
737during configuration if the ICU version is too old.
738
739#### Unix/macOS
740
741From an already-unpacked ICU:
742
743```console
744$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu
745```
746
747From a local ICU tarball:
748
749```console
750$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz
751```
752
753From a tarball URL:
754
755```console
756$ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz
757```
758
759#### Windows
760
761First unpack latest ICU to `deps/icu`
762[icu4c-**##.#**-src.tgz](http://site.icu-project.org/download) (or `.zip`)
763as `deps/icu` (You'll have: `deps/icu/source/...`)
764
765```console
766> .\vcbuild full-icu
767```
768
769## Building Node.js with FIPS-compliant OpenSSL
770
771The current version of Node.js does not support FIPS.
772
773## Building Node.js with external core modules
774
775It is possible to specify one or more JavaScript text files to be bundled in
776the binary as built-in modules when building Node.js.
777
778### Unix/macOS
779
780This command will make `/root/myModule.js` available via
781`require('/root/myModule')` and `./myModule2.js` available via
782`require('myModule2')`.
783
784```console
785$ ./configure --link-module '/root/myModule.js' --link-module './myModule2.js'
786```
787
788### Windows
789
790To make `./myModule.js` available via `require('myModule')` and
791`./myModule2.js` available via `require('myModule2')`:
792
793```console
794> .\vcbuild link-module './myModule.js' link-module './myModule2.js'
795```
796
797## Note for downstream distributors of Node.js
798
799The Node.js ecosystem is reliant on ABI compatibility within a major release.
800To maintain ABI compatibility it is required that distributed builds of Node.js
801be built against the same version of dependencies, or similar versions that do
802not break their ABI compatibility, as those released by Node.js for any given
803`NODE_MODULE_VERSION` (located in `src/node_version.h`).
804
805When Node.js is built (with an intention to distribute) with an ABI
806incompatible with the official Node.js builds (e.g. using a ABI incompatible
807version of a dependency), please reserve and use a custom `NODE_MODULE_VERSION`
808by opening a pull request against the registry available at
809<https://github.com/nodejs/node/blob/HEAD/doc/abi_version_registry.json>.
810