Skip to content
100644 74 lines (52 sloc) 3.73 KB
2a420a7 @tj No longer gitignoring html
tj authored
1 <div class='mp'>
2 <h1>Installing Node</h1>
fa384c9 @tj Regenerated book
tj authored
3 <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>
2a420a7 @tj No longer gitignoring html
tj authored
5 <h3 id="Homebrew">Homebrew</h3>
7 <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>
9 <pre><code>$ brew install node.js
10 </code></pre>
12 <h2 id="nDistro">nDistro</h2>
14 <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
15 module and node binary version dependencies. In the example
16 below we specify the node binary version <em>0.1.102</em>, as well as
17 several 3rd party modules.</p>
19 <pre><code>node 0.1.102
20 module senchalabs connect
21 module visionmedia express 1.0.0beta2
22 module visionmedia connect-form
23 module visionmedia connect-redis
24 module visionmedia jade
25 module visionmedia ejs
26 </code></pre>
28 <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>
30 <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>
32 <pre><code>$ cd /usr/local/bin &amp;&amp; curl | sh
33 </code></pre>
35 <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>
37 <pre><code>$ ndistro
38 </code></pre>
fa384c9 @tj Regenerated book
tj authored
40 <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>
2a420a7 @tj No longer gitignoring html
tj authored
42 <pre><code>... installing node-0.1.102-i386
43 ... installing connect
44 ... installing express 1.0.0beta2
45 ... installing bin/express
46 ... installing connect-form
47 ... installing connect-redis
48 ... installing jade
49 ... installing bin/jade
50 ... installing ejs
51 ... installation complete
52 </code></pre>
54 <h2 id="Building-From-Source">Building From Source</h2>
56 <p>To build and install node from source, we first need to obtain the code. The first method of doing so is
57 via <code>git</code>, if you have git installed you can execute:</p>
59 <pre><code>$ git clone &amp;&amp; cd node
60 </code></pre>
62 <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>
64 <pre><code>$ curl -# &gt; node.tar.gz
65 $ tar -zxf node.tar.gz
66 </code></pre>
68 <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>
70 <pre><code>$ ./configure &amp;&amp; make &amp;&amp; make install
71 </code></pre>
73 </div>
Something went wrong with that request. Please try again.