Installing Node.js

×

Status message

New Feature: Guest Login function added to facilitate site exploration without registering. Try it out!

There are a number of ways to install Node.js on your system. You can always find the latest installation instructions on the Node.js website. We will document below our recommended methods of installation for the smoothest path to success.

Before we get started, we would like to point out a couple of caveats.

You want to install and run Node in user space! You don't want to run any Node commands using sudo. If a command prompts you that sudo is required, you probably want to revisit your installation and make sure everything is configured as recommended. sudo can make things get weird, fast.

We recommend against using a package manager for installation. Yum, APT, Homebrew—all of these are great tools and generally recommended for everything. However, part of the Node installation is npm, the Node Package Manager. Installing a package manager with a package manager can cause strange behavior. Again, things get weird, fast.

Now, onto installation!

Method 1 - Using nvm

Node.js is a fast-moving technology and there are updates all the time. It is not uncommon for many developers to require multiple versions of node installed on their system at a time. The Node Version Manager, or nvm, solves this!

Unfortunately, nvm is not available for Windows at this time. There are some alternatives but as of this writing they have not been tested or vetted by Araport staff.

On OS X, you can install nvm using Homebrew:

$ brew install nvm

On Linux, you can install nvm using the install script via cURL:

$ curl https://raw.githubusercontent.com/creationix/nvm/v0.22.0/install.sh | bash

Once you have nvm, you will want to add the environment variable NVM_DIR and then source it from your shell. You can set both of these in your shell configuration file (e.g., $HOME/.bashrc, $HOME/.zshrc).

export NVM_DIR=~/.nvm
##
# If you installed via Homebrew on OS X, you can use the following:
#source $(brew --prefix nvm)/nvm.sh
#
source /path/to/nvm/nvm.sh

Once nvm is installed and configured, we will install the latest stable version of Node.js and set it as the default:

$ nvm install stable
$ nvm alias default stable
$ nvm use default

Now Node will be available in any shell.

Method 2 - Using local binaries

The next-simplest method to installing node is to simply install the binaries and configure them on your $PATH. Download the appropriate binary for your OS from http://nodejs.org/download/. Unpack the download and add the node and npm commands, found in node-v0.10.35-platform-x64/bin, to your $PATH.

Below is a summary of commands for doing this in a way that allows for easy upgrades of Node, simply by downloading a new binary to ~/.local/node and updating the ~/.local/node/latest symlink:

$ cd ~
$ mkdir -p .local/bin
$ mkdir -p .local/node
$ cd .local/node
$ curl -O http://nodejs.org/dist/v0.10.35/node-v0.10.35-darwin-x64.tar.gz
$ tar -xzf node-v0.10.35-darwin-x64.tar.gz
$ ln -s node-v0.10.35-darwin-x64 latest
$ cd ../bin
$ ln -s ../node/latest/bin/node
$ ln -s ../node/latest/bin/npm
$ echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc

Method 3 - Using the node installer

There are installers for Windows (.msi) and Mac OS X (.pkg) available from http://nodejs.org/download/. You may select to use one of these installers.

Method 4 - Compile from source (beast mode)

You can always download the source code for node from the node downloads page. This method works, but is generally unnecessary. One of the above methods should work. If it doesn't work, before you compile from source, we recommend that you contact Araport support and see if we can assist you with installing using one of the above methods.