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.
|
|
|
|
|
|
|
|
|
2016-04-20 17:48:22 +00:00
|
|
|
### Unix / OS X
|
2016-03-09 23:41:52 +00:00
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
|
|
|
|
* `gcc` and `g++` 4.8 or newer, or
|
|
|
|
* `clang` and `clang++` 3.4 or newer
|
|
|
|
* Python 2.6 or 2.7
|
|
|
|
* GNU Make 3.81 or newer
|
2016-04-20 17:48:22 +00:00
|
|
|
|
|
|
|
On OS X, you will also need:
|
|
|
|
* [Xcode](https://developer.apple.com/xcode/download/)
|
2016-11-18 17:40:45 +00:00
|
|
|
* You also need to install the `Command Line Tools` via Xcode. You can find
|
2016-04-20 17:48:22 +00:00
|
|
|
this under the menu `Xcode -> Preferences -> Downloads`
|
|
|
|
* This step will install `gcc` and the related toolchain containing `make`
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
$ make
|
|
|
|
```
|
|
|
|
|
2016-09-24 23:17:13 +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
|
|
|
|
|
|
|
To run the tests:
|
|
|
|
|
2016-07-14 09:55:30 +00:00
|
|
|
```console
|
2016-03-09 23:41:52 +00:00
|
|
|
$ make test
|
|
|
|
```
|
|
|
|
|
2016-04-15 18:15:03 +00:00
|
|
|
To run the npm test suite:
|
|
|
|
|
|
|
|
*note: to run the suite on node v4 or earlier you must first*
|
|
|
|
*run `make install`*
|
|
|
|
|
2016-07-14 09:55:30 +00:00
|
|
|
```console
|
2016-04-15 18:15:03 +00:00
|
|
|
$ make test-npm
|
|
|
|
```
|
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2015-11-18 22:40:03 +00:00
|
|
|
If you have an existing Node.js you can build just the docs with:
|
|
|
|
|
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/)
|
2016-06-13 10:24:53 +00:00
|
|
|
* One of:
|
|
|
|
* [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools)
|
2016-08-10 12:40:50 +00:00
|
|
|
* [Visual Studio 2015 Update 3](https://www.visualstudio.com/), all editions
|
|
|
|
including the Community edition.
|
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`.
|
|
|
|
|
2016-07-14 09:55:30 +00:00
|
|
|
```console
|
2016-09-21 22:37:26 +00:00
|
|
|
> .\vcbuild nosign
|
2016-03-09 23:41:52 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
To run the tests:
|
|
|
|
|
2016-07-14 09:55:30 +00:00
|
|
|
```console
|
2016-09-21 22:37:26 +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
|
|
|
```
|
|
|
|
|
2016-11-12 07:30:28 +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
|
|
|
|
|
|
|
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-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
|
|
|
|
2016-04-20 17:48:22 +00:00
|
|
|
##### Unix / OS X:
|
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
|
2016-09-21 22:37:26 +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
|
|
|
|
2016-04-20 17:48:22 +00:00
|
|
|
##### Unix / OS X:
|
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
|
2016-09-21 22:37:26 +00:00
|
|
|
> .\vcbuild without-intl
|
2016-03-09 23:41:52 +00:00
|
|
|
```
|
|
|
|
|
2016-04-20 17:48:22 +00:00
|
|
|
#### Use existing installed ICU (Unix / OS X 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`).
|
|
|
|
|
2016-04-20 17:48:22 +00:00
|
|
|
##### Unix / OS X
|
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
|
2016-09-21 22:37:26 +00:00
|
|
|
> .\vcbuild full-icu
|
2016-03-09 23:41:52 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Building Node.js with FIPS-compliant OpenSSL
|
|
|
|
|
|
|
|
NOTE: Windows is not yet supported
|
|
|
|
|
|
|
|
It is possible to build Node.js with
|
2016-10-28 11:27:03 +00:00
|
|
|
[OpenSSL FIPS module](https://www.openssl.org/docs/fipsnotes.html).
|
2016-03-09 23:41:52 +00:00
|
|
|
|
|
|
|
**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](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf)
|
|
|
|
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](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf).
|
|
|
|
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).
|
|
|
|
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](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
|
|
|
|
/usr/local/ssl/fips-2.0
|
|
|
|
8. Build Node.js with `make -j`
|
|
|
|
9. Verify with `node -p "process.versions.openssl"` (`1.0.2a-fips`)
|