Node.js on OSX

Node.js is a fun new technology. If you are looking to experiment with it, here is a quick start guide on how to install it for people using OSX

Macports is so 1995

Install Homebrew, a much better alternative to macports

    
    ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
    
    

Install Node.js and NPM

npm (Node Package Manager) is a nifty little tool to manage node packages

    brew install node
    brew install npm
    export NODE_PATH="/usr/local/lib/node"
    

That'll do it's thing and voila!, you now have node installed. To quickly test if this is working create a file called test.js. In the file paste the following contents

    var http = require('http');
    http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
    }).listen(8124, "127.0.0.1");
    console.log('Server running at http://127.0.0.1:8124/');
    

Now run and you should be able to hit http://127.0.0.1:8124/ to view the results

    node test.js
    

A few more packages to play with while you experiment:

    npm install expressjs
    
    npm install jsdom
    
    npm install yui3
    
    npm install yql
    

Unstructured Scribbles is powered by Express and Pure CSS. Opinions on this website are my own and not of my employer.