Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (52 sloc) 3.73 KB
<div class='mp'>
<h1>Installing Node</h1>
<p>In this chapter we will be looking at the installation and compilation of node. Although there are several ways we may install node, we will be looking at <a href="">homebrew</a>, <a href="">nDistro</a>, and the most flexible method, of course - compiling from source.</p>
<h3 id="Homebrew">Homebrew</h3>
<p>Homebrew is a package management system for <em>OSX</em> written in Ruby, is extremely well adopted, and easy to use. To install node via the <code>brew</code> executable simply run:</p>
<pre><code>$ brew install node.js
<h2 id="nDistro">nDistro</h2>
<p><a href="">nDistro</a> is a distribution toolkit for node, which allows creation and installation of node distros within seconds. An <em>nDistro</em> is simply a dotfile named <em>.ndistro</em> which defines
module and node binary version dependencies. In the example
below we specify the node binary version <em>0.1.102</em>, as well as
several 3rd party modules.</p>
<pre><code>node 0.1.102
module senchalabs connect
module visionmedia express 1.0.0beta2
module visionmedia connect-form
module visionmedia connect-redis
module visionmedia jade
module visionmedia ejs
<p>Any machine that can run a shell script can install distributions, and keeps dependencies defined to a single directory structure, making it easy to maintain an deploy. nDistro uses <a href="">pre-compiled node binaries</a> making them extremely fast to install, and module tarballs which are fetched from <a href="">GitHub</a> via <em>wget</em> or <em>curl</em> (auto detected).</p>
<p>To get started we first need to install nDistro itself, below we <em>cd</em> to our bin directory of choice, <em>curl</em> the shell script, and pipe the response to <em>sh</em> which will install nDistro to the current directory:</p>
<pre><code>$ cd /usr/local/bin &amp;&amp; curl | sh
<p>Next we can place the contents of our example in <em>./.ndistro</em>, and execute <em>ndistro</em> with no arguments, prompting the program to load the config, and start installing:</p>
<pre><code>$ ndistro
<p>Installation of the example took less than 17 seconds on my machine, and outputs the following <em>stdout</em> indicating success. Not bad for an entire stack!</p>
<pre><code>... installing node-0.1.102-i386
... installing connect
... installing express 1.0.0beta2
... installing bin/express
... installing connect-form
... installing connect-redis
... installing jade
... installing bin/jade
... installing ejs
... installation complete
<h2 id="Building-From-Source">Building From Source</h2>
<p>To build and install node from source, we first need to obtain the code. The first method of doing so is
via <code>git</code>, if you have git installed you can execute:</p>
<pre><code>$ git clone &amp;&amp; cd node
<p>For those without <em>git</em>, or who prefer not to use it, we can also download the source via <em>curl</em>, <em>wget</em>, or similar:</p>
<pre><code>$ curl -# &gt; node.tar.gz
$ tar -zxf node.tar.gz
<p>Now that we have the source on our machine, we can run <code>./configure</code> which discovers which libraries are available for node to utilize such as <em>OpenSSL</em> for transport security support, C and C++ compilers, etc. <code>make</code> which builds node, and finally <code>make install</code> which will install node.</p>
<pre><code>$ ./configure &amp;&amp; make &amp;&amp; make install
Jump to Line
Something went wrong with that request. Please try again.