Skip to content

Latest commit

 

History

History
354 lines (259 loc) · 11.4 KB

BUILDING.md

File metadata and controls

354 lines (259 loc) · 11.4 KB

Building Node.js

Depending on what platform or features you require, the build process may 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 or file a new issue.

Supported platforms

This list of supported platforms is current as of the branch / release to 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.
  • 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.

Supported platforms

System Support type Version Architectures Notes
GNU/Linux Tier 1 kernel >= 2.6.18, glibc >= 2.5 x86, x64, arm, arm64
macOS Tier 1 >= 10.10 x64
Windows Tier 1 >= Windows 7 or >= Windows2008R2 x86, x64
SmartOS Tier 2 >= 15 < 16.4 x86, x64 see note1
FreeBSD Tier 2 >= 10 x64
GNU/Linux Tier 2 kernel >= 4.2.0, glibc >= 2.19 ppc64be
GNU/Linux Tier 2 kernel >= 3.13.0, glibc >= 2.19 ppc64le
AIX Tier 2 >= 6.1 TL09 ppc64be
GNU/Linux Tier 2 kernel >= 3.10, glibc >= 2.17 s390x
macOS Experimental >= 10.8 < 10.10 x64 no test coverage
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

Supported toolchains

Depending on host platform, the selection of toolchains may vary.

Unix

  • GCC 4.8.5 or newer
  • Clang 3.4.1 or newer

Windows

  • Building Node: Visual Studio 2015 or Visual C++ Build Tools 2015 or newer
  • Building native add-ons: Visual Studio 2013 or Visual C++ Build Tools 2015 or newer

Building Node.js on supported platforms

Unix / macOS

Prerequisites:

  • gcc and g++ 4.8.5 or newer, or
  • clang and clang++ 3.4.1 or newer
  • Python 2.6 or 2.7
  • GNU Make 3.81 or newer

On macOS, you will also need:

  • Xcode

    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
    • This step will install gcc and the related toolchain containing make
  • After building, you may want to setup firewall rules to avoid popups asking to accept incoming network connections when running tests:

$ sudo ./tools/macosx-firewall.sh

Running this script will add rules for the executable node in the out directory and the symbolic node link in the project's root directory.

On FreeBSD and OpenBSD, you may also need:

  • libexecinfo

To build Node.js:

$ ./configure
$ make -j4

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 for more information.

Note that the above requires that python resolve to Python 2.6 or 2.7 and not a newer version.

To run the tests:

$ make test

To run the npm test suite:

note: to run the suite on node v4 or earlier you must first run make install

$ make test-npm

To build the documentation:

This will build Node.js first (if necessary) and then use it to build the docs:

$ make doc

If you have an existing Node.js you can build just the docs with:

$ NODE=/path/to/node make doc-only

To read the documentation:

$ man doc/node.1

To test if Node.js was built correctly:

$ ./node -e "console.log('Hello from Node.js ' + process.version)"

To install this version of Node.js into a system directory:

$ [sudo] make install

Windows

Prerequisites:

> .\vcbuild

To run the tests:

> .\vcbuild test

To test if Node.js was built correctly:

> Release\node -e "console.log('Hello from Node.js', process.version)"

Android / Android-based devices (e.g. Firefox OS)

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.

Be sure you have downloaded and extracted Android NDK before in a folder. Then run:

$ ./android-configure /path/to/your/android-ndk
$ make

Intl (ECMA-402) support:

Intl support is enabled by default, with English data only.

Default: small-icu (English only) support

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 data at runtime.

Note: more docs are on the node wiki.

Build with full ICU support (all locales supported by ICU):

With the --download=all, this may download ICU if you don't have an ICU in deps/icu. (The embedded small-icu included in the default Node.js source does not include all locales.)

Unix / macOS:
$ ./configure --with-intl=full-icu --download=all
Windows:
> .\vcbuild full-icu download-all

Building without Intl support

The Intl object will not be available, nor some other APIs such as String.normalize.

Unix / macOS:
$ ./configure --without-intl
Windows:
> .\vcbuild without-intl

Use existing installed ICU (Unix / macOS only):

$ 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. Download the file named something like icu4c-**##.#**-src.tgz (or .zip).

Unix / macOS

From an already-unpacked ICU:

$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu

From a local ICU tarball:

$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz

From a tarball URL:

$ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz
Windows

First unpack latest ICU to deps/icu icu4c-##.#-src.tgz (or .zip) as deps/icu (You'll have: deps/icu/source/...)

> .\vcbuild full-icu

Building Node.js with FIPS-compliant OpenSSL

NOTE: Windows is not yet supported

It is possible to build Node.js with OpenSSL FIPS module.

Note: building in this way does not allow you to claim that the runtime is FIPS 140-2 validated. Instead you can indicate that the runtime uses a validated module. See the security policy page 60 for more details. In addition, the validation for the underlying module is only valid if it is deployed in accordance with its security policy. If you need FIPS validated cryptography it is recommended that you read both the security policy and user guide.

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. For evaluation/experimentation you can simply download and verify 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. 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 /usr/local/ssl/fips-2.0
  8. Build Node.js with make -j
  9. Verify with node -p "process.versions.openssl" (for example 1.0.2a-fips)