-
Notifications
You must be signed in to change notification settings - Fork 79
Home
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.
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.
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
This can occur if you have more than one disk drive and your home directory is physically mounted on a volume that might have a space in its name, such as "Macintosh HD":
$ df
/dev/disk2 ... /
/dev/disk1s2 ... /Volumes/Macintosh HD
The easiest solution is to avoid building a Node version to any path that has space characters in it.
So instead of building into ~/.nodenv/versions/<version>
, which is the default for nodenv install <version>
,
instead you could install into /opt/nodes/<version>
and symlink /opt/nodes
as ~/.nodenv/versions
so nodenv continues to work as before:
sudo mkdir -p /opt/nodes
sudo chown "${USER}:staff" /opt/nodes
rm -rf ~/.nodenv/versions # This will DELETE your existing Node versions!
ln -s /opt/nodes ~/.nodenv/versions
Now proceed as following:
ruby-build <version> /opt/nodes/<version>
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
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