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