Skip to content
Jason Karns edited this page Jan 5, 2019 · 3 revisions

node-build is a tool that downloads and compiles various versions of Node. It is exposed as nodenv install through nodenv or simply as node-build when used standalone.

Suggested build environment

node-build will try its best to download and compile the wanted Node version, but sometimes compilation fails because of unmet system dependencies, or compilation succeeds but the new Node version exhibits weird failures at runtime. We recommend nodejs' guide for building from source and setting up your system with the necessary pre-requisites.

Notes

Updating node-build

If you have trouble installing a Node version, first try to update node-build to get the latest bug fixes and Node definitions.

First locate it on your system:

which node-build
ls "$(nodenv root)"/plugins

If it's in /usr/local/bin on a Mac, you've probably installed it via Homebrew:

brew upgrade node-build

Or, if you have it installed via git as an nodenv plugin:

cd "$(nodenv root)"/plugins/node-build && git pull

Troubleshooting

No space left on device

Some distributions will mount a tmpfs partition with low disk space to /tmp, such as 250 MB. You can check this with:

mount | grep tmp
df -h | grep tmp

Compiling MRI requires at least 265 MB, so you should temporarily resize /tmp to allow more usage:

rm -rf /tmp/node-build*
mount -o remount,size=300M,noatime /tmp

Lower the number of parallel jobs

On hosts that report a large amount of CPU cores, but don't have plenty of RAM, you might get:

gcc: internal compiler error: Killed (program cc1)

The solution is to use MAKE_OPTS=-j2 to limit make to maximum of 2 parallel processes:

export MAKE_OPTS=-j2

or also with writable temp directory:

TMPDIR=~/tmp MAKE_OPTS=-j2 nodenv install 8.0.0

Clone this wiki locally