Skip to content

Installation

chowey edited this page Sep 5, 2011 · 81 revisions

Building and Installing Node.js

Step 1 - Pick Your Platform

Node should install out of the box on Linux, Macintosh, and Solaris.

With some effort you should be able to get it running on other Unix platforms and Windows (either via Cygwin or MinGW). Native Windows support is a work-in-progress and you can download the latest release: Windows Build (Node v0.5.5). It's unstable and things are expected to break. NPM support might be added in future. If you find any bugs, please report them to issue tracker.

Mac OSX users also have the option of installing a precompiled package from here that includes npm.

Step 2 - Prerequisites

Node has several dependencies, but fortunately most of them are distributed along with it. If you are building from source you should only need 2 things.

  • python - version 2.6 or higher. The build tools distributed with Node run on python.

  • libssl-dev - If you plan to use SSL/TLS encryption in your networking, you'll need this. Libssl is the library used in the openssl tool. On Linux and Unix systems it can usually be installed with your favorite package manager. The lib comes pre- installed on OS X.

Step 3a - Installing on Unix (including BSD and Mac)

Building from source

Use make to build and install Node (execute the following on the command line)

git clone --depth 1 git://github.com/joyent/node.git # or git clone git://github.com/joyent/node.git if you want to checkout a stable tag
cd node
git checkout v0.4.11 # optional.  Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
echo 'export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules' >> ~/.profile
source ~/.profile

If you have any installation problems, look at Troubleshooting Installation, try an alternate installation method, or stop into #node.js and ask questions.

sudo apt-get install node Wont work on ubuntu/debian machines. That is a different package with the same name. Use the above method itself for installing node.

Pre-built binaries

You can also install node from packages: Installing Node.js via package manager

Step 3b - Building on Windows

Pre-built binaries

Windows Build (Node v0.5.5): http://nodejs.org/dist/v0.5.5/node.exe Self-contained binaries are available at node-js.prcn.co.cc

Building from source

There are three ways of building Node on Windows. One is over the Cygwin emulation layer, another is using MinGW (GNU toolchain for windows), and the last way is using VC++. See the Cygwin and MinGW pages.

Neither builds are satisfactorily stable but it is possible to get something running.

Building with VC++

There is increasing support for native compilation on Windows using VC++ (Visual C++). This includes Visual C++ Express which is available for free from Microsoft. First download the node source. Then, from the Visual Studio Command Prompt, type

cd c:\path\to\source
vcbuild.bat debug

for the debug version or

cd c:\path\to\source
vcbuild.bat release

for the release version to build node.

Hosting in IIS on Windows

It is possible to host node.js application in IIS on Windows using the iisnode IIS module. More details available here.

Step 4 - Install NPM

NPM is a package manager that has become the de-facto standard for installing additional node libraries and programs. Here's the quick and easy one-liner for installing on Unix.

# curl http://npmjs.org/install.sh | sh

To install a library e.g. Express:

# npm install express

And visit https://github.com/isaacs/npm for details.

Clone this wiki locally