2016-09-20 04:54:35 +00:00
# Building Node.js
2016-03-09 23:41:52 +00:00
2016-09-03 03:23:21 +00:00
Depending on what platform or features you require, the build process may
2016-03-09 23:41:52 +00:00
differ slightly. After you've successfully built a binary, running the
test suite to validate that the binary works as intended is a good next step.
If you consistently can reproduce a test failure, search for it in the
[Node.js issue tracker ](https://github.com/nodejs/node/issues ) or
file a new issue.
2017-03-17 21:34:54 +00:00
## Supported platforms
2018-01-04 23:37:53 +00:00
This list of supported platforms is current as of the branch/release to
2017-03-17 21:34:54 +00:00
which it is attached.
### Input
Node.js relies on V8 and libuv. Therefore, we adopt a subset of their
supported platforms.
### Strategy
Support is divided into three tiers:
* **Tier 1**: Full test coverage and maintenance by the Node.js core team and
the broader community.
* **Tier 2**: Full test coverage but more limited maintenance,
often provided by the vendor of the platform.
2017-04-01 08:07:31 +00:00
* **Experimental**: May not compile reliably or test suite may not pass.
These are often working to be promoted to Tier 2 but are not quite ready.
There is at least one individual actively providing maintenance and the team
is striving to broaden quality and reliability of support.
2017-03-17 21:34:54 +00:00
### Supported platforms
2018-01-04 23:37:53 +00:00
The community does not build or test against end-of-life distributions (EoL).
Thus we do not recommend that you use Node on end-of-life or unsupported platforms
2017-04-26 16:59:53 +00:00
in production.
2017-03-17 21:34:54 +00:00
| System | Support type | Version | Architectures | Notes |
|--------------|--------------|----------------------------------|----------------------|------------------|
2017-11-03 17:40:17 +00:00
| GNU/Linux | Tier 1 | kernel >= 2.6.32, glibc >= 2.12 | x64, arm, arm64 | |
2017-03-17 21:34:54 +00:00
| macOS | Tier 1 | >= 10.10 | x64 | |
2018-01-04 23:37:53 +00:00
| Windows | Tier 1 | >= Windows 7/2008 R2 | x86, x64 | vs2017 |
2017-03-17 21:34:54 +00:00
| SmartOS | Tier 2 | >= 15 < 16.4 | x86 , x64 | see note1 |
| FreeBSD | Tier 2 | >= 10 | x64 | |
2017-04-26 21:40:56 +00:00
| GNU/Linux | Tier 2 | kernel >= 3.13.0, glibc >= 2.19 | ppc64le >=power8 | |
| AIX | Tier 2 | >= 7.1 TL04 | ppc64be >=power7 | |
2017-03-17 21:34:54 +00:00
| GNU/Linux | Tier 2 | kernel >= 3.10, glibc >= 2.17 | s390x | |
| macOS | Experimental | >= 10.8 < 10.10 | x64 | no test coverage |
2017-11-03 17:40:17 +00:00
| GNU/Linux | Experimental | kernel >= 2.6.32, glibc >= 2.12 | x86 | limited CI |
2017-03-17 21:34:54 +00:00
| Linux (musl) | Experimental | musl >= 1.0 | x64 | |
note1 - The gcc4.8-libs package needs to be installed, because node
binaries have been built with GCC 4.8, for which runtime libraries are not
installed by default. For these node versions, the recommended binaries
are the ones available in pkgsrc, not the one available from nodejs.org.
Note that the binaries downloaded from the pkgsrc repositories are not
officially supported by the Node.js project, and instead are supported
by Joyent. SmartOS images >= 16.4 are not supported because
GCC 4.8 runtime libraries are not available in their pkgsrc repository
2017-10-09 17:10:54 +00:00
*Note*: On Windows, running Node.js in windows terminal emulators like `mintty`
requires the usage of [winpty ](https://github.com/rprichard/winpty ) for
Node's tty channels to work correctly (e.g. `winpty node.exe script.js` ).
In "Git bash" if you call the node shell alias (`node` without the `.exe`
extension), `winpty` is used automatically.
2017-11-14 02:44:25 +00:00
The Windows Subsystem for Linux (WSL) is not directly supported, but the
GNU/Linux build process and binaries should work. The community will only
address issues that reproduce on native GNU/Linux systems. Issues that only
reproduce on WSL should be reported in the
[WSL issue tracker ](https://github.com/Microsoft/WSL/issues ). Running the
Windows binary (`node.exe`) in WSL is not recommended, and will not work
without adjustment (such as stdio redirection).
2017-03-17 21:34:54 +00:00
### Supported toolchains
Depending on host platform, the selection of toolchains may vary.
#### Unix
2017-06-05 08:53:54 +00:00
* GCC 4.9.4 or newer
2017-04-13 10:42:56 +00:00
* Clang 3.4.2 or newer
2017-03-17 21:34:54 +00:00
#### Windows
2017-11-07 17:36:09 +00:00
* Visual Studio 2017 or the Build Tools thereof
2017-03-17 21:34:54 +00:00
## Building Node.js on supported platforms
2016-03-09 23:41:52 +00:00
2017-11-14 14:57:11 +00:00
*Note:* All prerequisites can be easily installed by following
[this bootstrapping guide ](https://github.com/nodejs/node/blob/master/tools/bootstrap/README.md ).
2018-01-04 23:37:53 +00:00
### Unix/macOS
2016-03-09 23:41:52 +00:00
2018-01-09 11:34:11 +00:00
#### Prerequisites
2016-03-09 23:41:52 +00:00
2017-06-05 08:53:54 +00:00
* `gcc` and `g++` 4.9.4 or newer, or
* `clang` and `clang++` 3.4.2 or newer (macOS: latest Xcode Command Line Tools)
2016-03-09 23:41:52 +00:00
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
2016-04-20 17:48:22 +00:00
2018-01-04 23:37:53 +00:00
On macOS, you will need to install the `Xcode Command Line Tools` by running
2017-05-28 10:57:35 +00:00
`xcode-select --install` . Alternatively, if you already have the full Xcode
installed, you can find them under the menu `Xcode -> Open Developer Tool ->
More Developer Tools...`. This step will install `clang` , `clang++` , and
`make` .
2017-10-06 16:45:03 +00:00
* After building, you may want to setup [firewall rules ](tools/macosx-firewall.sh )
2016-12-17 01:28:59 +00:00
to avoid popups asking to accept incoming network connections when running tests:
2016-12-03 06:56:01 +00:00
2017-07-18 19:03:43 +00:00
If the path to your build directory contains a space, the build will likely fail.
2016-12-03 06:56:01 +00:00
```console
$ sudo ./tools/macosx-firewall.sh
```
2018-01-04 23:37:53 +00:00
Running this script will add rules for the executable `node` in the `out`
2017-04-01 08:07:31 +00:00
directory and the symbolic `node` link in the project's root directory.
2016-12-03 06:56:01 +00:00
2016-04-20 17:48:22 +00:00
On FreeBSD and OpenBSD, you may also need:
2016-09-03 03:23:21 +00:00
* libexecinfo
2016-03-09 23:41:52 +00:00
2018-01-09 11:34:11 +00:00
#### Building Node.js
2016-09-03 03:23:21 +00:00
To build Node.js:
2016-04-20 17:48:22 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ ./configure
2016-12-01 16:47:46 +00:00
$ make -j4
2016-03-09 23:41:52 +00:00
```
2016-12-01 16:47:46 +00:00
Running `make` with the `-j4` flag will cause it to run 4 compilation jobs
concurrently which may significantly reduce build time. The number after `-j`
can be changed to best suit the number of processor cores on your machine. If
you run into problems running `make` with concurrency, try running it without
the `-j4` flag. See the
[GNU Make Documentation ](https://www.gnu.org/software/make/manual/html_node/Parallel.html )
for more information.
2017-03-17 21:34:54 +00:00
Note that the above requires that `python` resolve to Python 2.6 or 2.7
and not a newer version.
2016-03-09 23:41:52 +00:00
2018-01-09 11:34:11 +00:00
#### Running Tests
To verify the build:
```console
$ make test-only
```
At this point, you are ready to make code changes and re-run the tests.
If you are running tests prior to submitting a Pull Request, the recommended
command is:
2016-03-09 23:41:52 +00:00
2017-05-28 20:20:21 +00:00
```console
2016-03-09 23:41:52 +00:00
$ make test
```
2018-01-09 11:34:11 +00:00
`make test` does a full check on the codebase, including running linters and
documentation tests.
2017-10-06 17:42:35 +00:00
Optionally, continue below.
2017-09-04 22:10:05 +00:00
To run the tests and generate code coverage reports:
```console
$ ./configure --coverage
$ make coverage
```
This will generate coverage reports for both JavaScript and C++ tests (if you
only want to run the JavaScript tests then you do not need to run the first
command `./configure --coverage` ).
The `make coverage` command downloads some tools to the project root directory
and overwrites the `lib/` directory. To clean up after generating the coverage
reports:
```console
2017-10-06 17:42:35 +00:00
$ make coverage-clean
2017-09-04 22:10:05 +00:00
```
2018-01-09 11:34:11 +00:00
#### Building the documentation
2016-03-09 23:41:52 +00:00
To build the documentation:
2015-11-18 22:40:03 +00:00
This will build Node.js first (if necessary) and then use it to build the docs:
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ make doc
```
2017-08-18 18:36:33 +00:00
If you have an existing Node.js build, you can build just the docs with:
2015-11-18 22:40:03 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-09-03 03:23:21 +00:00
$ NODE=/path/to/node make doc-only
2015-11-18 22:40:03 +00:00
```
2016-03-09 23:41:52 +00:00
To read the documentation:
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ man doc/node.1
```
To test if Node.js was built correctly:
2016-07-14 09:55:30 +00:00
```console
2016-09-03 03:23:21 +00:00
$ ./node -e "console.log('Hello from Node.js ' + process.version)"
```
To install this version of Node.js into a system directory:
```console
$ [sudo] make install
2016-03-09 23:41:52 +00:00
```
### Windows
Prerequisites:
* [Python 2.6 or 2.7 ](https://www.python.org/downloads/ )
2017-11-07 17:36:09 +00:00
* The "Desktop development with C++" workload from
[Visual Studio 2017 ](https://www.visualstudio.com/downloads/ ) or the
"Visual C++ build tools" workload from the
[Build Tools ](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 ),
with the default optional components.
2016-03-09 23:41:52 +00:00
* Basic Unix tools required for some tests,
[Git for Windows ](http://git-scm.com/download/win ) includes Git Bash
and tools which can be included in the global `PATH` .
2017-11-17 17:54:06 +00:00
* **Optional** (to build the MSI): the [WiX Toolset v3.11 ](http://wixtoolset.org/releases/ )
and the [Wix Toolset Visual Studio 2017 Extension ](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension ).
2016-03-09 23:41:52 +00:00
2017-11-04 01:10:10 +00:00
If the path to your build directory contains a space or a non-ASCII character, the
build will likely fail.
2017-07-18 19:03:43 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-12-06 20:52:59 +00:00
> .\vcbuild
2016-03-09 23:41:52 +00:00
```
To run the tests:
2016-07-14 09:55:30 +00:00
```console
2017-01-16 16:25:00 +00:00
> .\vcbuild test
2016-03-09 23:41:52 +00:00
```
To test if Node.js was built correctly:
2016-07-14 09:55:30 +00:00
```console
2016-06-13 10:24:53 +00:00
> Release\node -e "console.log('Hello from Node.js', process.version)"
2016-03-09 23:41:52 +00:00
```
2018-01-04 23:37:53 +00:00
### Android/Android-based devices (e.g. Firefox OS)
2016-04-04 17:48:34 +00:00
Although these instructions for building on Android are provided, please note
that Android is not an officially supported platform at this time. Patches to
improve the Android build are accepted. However, there is no testing on Android
in the current continuous integration environment. The participation of people
dedicated and determined to improve Android building, testing, and support is
encouraged.
2016-03-09 23:41:52 +00:00
2017-04-01 08:07:31 +00:00
Be sure you have downloaded and extracted
[Android NDK ](https://developer.android.com/tools/sdk/ndk/index.html ) before in
a folder. Then run:
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ ./android-configure /path/to/your/android-ndk
$ make
```
### `Intl` (ECMA-402) support:
2016-04-09 02:03:24 +00:00
[Intl ](https://github.com/nodejs/node/wiki/Intl ) support is
enabled by default, with English data only.
2016-03-09 23:41:52 +00:00
2016-04-09 02:03:24 +00:00
#### Default: `small-icu` (English only) support
2016-03-09 23:41:52 +00:00
2016-04-09 02:03:24 +00:00
By default, only English data is included, but
the full `Intl` (ECMA-402) APIs. It does not need to download
any dependencies to function. You can add full
2016-03-09 23:41:52 +00:00
data at runtime.
*Note:* more docs are on
[the node wiki ](https://github.com/nodejs/node/wiki/Intl ).
#### Build with full ICU support (all locales supported by ICU):
With the `--download=all` , this may download ICU if you don't have an
2016-04-09 02:03:24 +00:00
ICU in `deps/icu` . (The embedded `small-icu` included in the default
Node.js source does not include all locales.)
2016-03-09 23:41:52 +00:00
2018-01-04 23:37:53 +00:00
##### Unix/macOS:
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ ./configure --with-intl=full-icu --download=all
```
##### Windows:
2016-07-14 09:55:30 +00:00
```console
2017-01-16 16:25:00 +00:00
> .\vcbuild full-icu download-all
2016-03-09 23:41:52 +00:00
```
#### Building without Intl support
2016-04-09 02:03:24 +00:00
The `Intl` object will not be available, nor some other APIs such as
`String.normalize` .
2016-03-09 23:41:52 +00:00
2018-01-04 23:37:53 +00:00
##### Unix/macOS:
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-04-09 02:03:24 +00:00
$ ./configure --without-intl
2016-03-09 23:41:52 +00:00
```
##### Windows:
2016-07-14 09:55:30 +00:00
```console
2017-01-16 16:25:00 +00:00
> .\vcbuild without-intl
2016-03-09 23:41:52 +00:00
```
2018-01-04 23:37:53 +00:00
#### Use existing installed ICU (Unix/macOS only):
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
```console
2016-03-09 23:41:52 +00:00
$ pkg-config --modversion icu-i18n & & ./configure --with-intl=system-icu
```
If you are cross compiling, your `pkg-config` must be able to supply a path
that works for both your host and target environments.
#### Build with a specific ICU:
You can find other ICU releases at
[the ICU homepage ](http://icu-project.org/download ).
Download the file named something like `icu4c-**##.#**-src.tgz` (or
`.zip` ).
2018-01-04 23:37:53 +00:00
##### Unix/macOS
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
From an already-unpacked ICU:
```console
2016-03-09 23:41:52 +00:00
$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu
2016-07-14 09:55:30 +00:00
```
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
From a local ICU tarball:
```console
2016-03-09 23:41:52 +00:00
$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz
2016-07-14 09:55:30 +00:00
```
2016-03-09 23:41:52 +00:00
2016-07-14 09:55:30 +00:00
From a tarball URL:
```console
2016-03-09 23:41:52 +00:00
$ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz
```
##### Windows
First unpack latest ICU to `deps/icu`
[icu4c-**##.#**-src.tgz ](http://icu-project.org/download ) (or `.zip` )
as `deps/icu` (You'll have: `deps/icu/source/...` )
2016-07-14 09:55:30 +00:00
```console
2017-01-16 16:25:00 +00:00
> .\vcbuild full-icu
2016-03-09 23:41:52 +00:00
```
## Building Node.js with FIPS-compliant OpenSSL
2017-12-07 22:49:57 +00:00
It is possible to build Node.js with the
[OpenSSL FIPS module ](https://www.openssl.org/docs/fipsnotes.html ) on POSIX
systems. Windows is not supported.
2016-03-09 23:41:52 +00:00
2017-12-07 22:49:57 +00:00
Building in this way does not mean the runtime is FIPS 140-2 validated, but
rather that the runtime uses a validated module. In addition, the validation for
the underlying module is only valid if it is deployed in accordance with its
2017-03-17 21:34:54 +00:00
[security policy ](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf ).
2016-03-09 23:41:52 +00:00
If you need FIPS validated cryptography it is recommended that you read both
the [security policy ](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf )
and [user guide ](https://openssl.org/docs/fips/UserGuide-2.0.pdf ).
### Instructions
1. Obtain a copy of openssl-fips-x.x.x.tar.gz.
To comply with the security policy you must ensure the path
through which you get the file complies with the requirements
for a "secure installation" as described in section 6.6 in
the [user guide ](https://openssl.org/docs/fips/UserGuide-2.0.pdf ).
2018-01-04 23:37:53 +00:00
For evaluation/experimentation, you can simply download and verify
2016-03-09 23:41:52 +00:00
`openssl-fips-x.x.x.tar.gz` from https://www.openssl.org/source/
2. Extract source to `openssl-fips` folder and `cd openssl-fips`
3. `./config`
4. `make`
5. `make install`
(NOTE: to comply with the security policy you must use the exact
commands in steps 3-5 without any additional options as per
Appendix A in the [security policy ](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf ).
The only exception is that `./config no-asm` can be
used in place of `./config` , and the FIPSDIR environment variable
may be used to specify a non-standard install folder for the
validated module, as per User Guide sections 4.2.1, 4.2.2, and 4.2.3.
6. Get into Node.js checkout folder
7. `./configure --openssl-fips=/path/to/openssl-fips/installdir`
For example on ubuntu 12 the installation directory was
2017-04-01 08:07:31 +00:00
`/usr/local/ssl/fips-2.0`
2016-03-09 23:41:52 +00:00
8. Build Node.js with `make -j`
2017-04-01 08:07:31 +00:00
9. Verify with `node -p "process.versions.openssl"` (for example `1.0.2a-fips` )