Installing node.js on ubuntu 10.04


With all the euphoria about node.js since the last few months, I finally decided to give it a try. As it is not available for Windows, I decided to install it on Linux instead of going for Windows/Cygwin. node.js is a implementation of CommonJS, a JavaScript ecosystem in development to be used for developing application outside the browser, like:

- Server-side JavaScript applications
- Command line tools
- Desktop GUI-based applications

Installing node.js

As mine was a clean Ubuntu installation, I needed to install certain libraries first.

sudo apt-get install g++ curl libssl-dev apache2-utils

The easiest way is to download node.js is to get a git clone. For that I needed to install the git package.

sudo apt-get install git-core

Now download node.js with git.

git clone git://github.com/ry/node.git

If you do not want to use git you could get the tar package instead.

wget http://nodejs.org/dist/node-v0.1.96.tar.gz
gunzip node-v0.1.96.tar.gz
tar -xf node-v0.1.96.tar

Now you are ready to install node.js.

cd node
./configure
make
sudo make install

Example node.js code

Below is a simple program using node.js for translating text using google API.

var http = require('http');
 
var url = ('ajax.googleapis.com')
var google = http.createClient(80, url);
 
var text = "Hello World from node!";
var requestUrl = '/ajax/services/language/translate?v=1.0&q=' + 
                 escape(text) + '&langpair=en%7Cfr'
var request = google.request('GET', requestUrl, 
              {"host": "ajax.googleapis.com"});
request.end();
 
request.addListener('response', function (response) {
  	var body = '';
 
	response.addListener('data', function (chunk) {
		body += chunk;
    });
 
    response.addListener("end", function() {
        var jsonData = JSON.parse(body);
	    console.log(jsonData.responseData.translatedText);
    })
 
});

This simple example does not to justice to the true power of node.js. I’ll be posting useful examples in the near future. Keep watching.

This site is a digital habitat of Sameer Borate, a freelance web developer working in PHP, MySQL and WordPress. I also provide web scraping services, website design and development and integration of various Open Source API's. Contact me at metapix[at]gmail.com for any new project requirements and price quotes.

25 Responses

1

ndrew

July 13th, 2010 at 12:36 am

simple tutorial, this is what i need..
thanks..

2

Brando Bandit

August 12th, 2010 at 3:51 am

Thanks for this man! I will try this one…

3

Jerome Etienne

August 20th, 2010 at 2:56 am

There is a simpler way to install. nodejs deb package is availble on ubuntu repository.

just copy this single line in a terminal

sudo add-apt-repository ppa:jerome-etienne/neoip && sudo apt-get update && sudo apt-get install nodejs

http://blog.jetienne.com/2010/08/nodejs-deb-package-on-ubuntu-repository.html

4

GMTAZ.com » Blog Archive » Node.js, Faye, Apache Proxies, Nginx and Websockets [WTF]

August 26th, 2010 at 5:11 pm

[...] 1.A: Get Node.js installed. Step 1.B: Get nginx installed. “sudo apt install [...]

5

Kevin Whinnery

October 24th, 2010 at 12:51 pm

Right on man, this worked for me right out of the box on my fresh ubuntu install. Thanks for sharing…

6

getting started with Node.js « Erik's blog

November 22nd, 2010 at 12:52 pm

[...] found what appears to be a nice tutorial for installing Node on Ubuntu 10.4, so I’ll start with [...]

7

Mike Comstock » Trying out Node.js with EC2

December 13th, 2010 at 11:59 pm

[...] Installing node.js on ubuntu 10.04 by Sameer Borate [...]

8

Steve Midgley

December 23rd, 2010 at 10:58 am

Perfect bootstrap article! Thank you. Got me started..

9

webkul

December 26th, 2010 at 1:59 pm

very nice ans simple tuts

10

Suopte

December 26th, 2010 at 4:15 pm

Thank you for this great, simple tutorial!

11

Sam Dutton

January 4th, 2011 at 4:03 am

Many thanks – well written, clear and complete.

The following site also has a useful tutorial for getting started with node.js:

http://net.tutsplus.com/tutorials/javascript-ajax/learning-serverside-javascript-with-node-js/

12

Thai Bui

January 7th, 2011 at 11:16 pm

Very nice. I got up and running in no time. I can’t wait to see what else you’ll publish with node.js. Thank you!

13

Ganesh Kumar

February 25th, 2011 at 7:40 am

Good One… Thanks a lot

14

Anony

April 29th, 2011 at 1:36 pm

$ git clone git://github.com/ry/node.git
Cloning into node…
fatal: remote error:
Could not find Repository ry/node

15

Banx

May 2nd, 2011 at 8:32 am

Update : The node.js source files are now located at github.com/joyent/node.git

16

laabroo

May 14th, 2011 at 1:40 pm

thanks to your tutorial brader.

17

Andrew

May 15th, 2011 at 11:06 am

Beside the new repo location, it’s also likely you will want a more stable version, rather than the latest. At the root of the repo, after cloning and before building:

git checkout v0.4.7

(v0.4.7 as an example)

18

New language to the toolset: NodeJS - Refactored scope

May 16th, 2011 at 2:35 pm

[...] the meantime as I use Ubuntu for everything but games, this short article here ( http://www.codediesel.com/linux/installing-node-js-on-ubuntu-10-04/ ) was enough to get a working [...]

19

Amar D Guru

May 30th, 2011 at 6:58 am

Thanks for the straightforward and accurate instructions to get started with node.

20

Sachin Pethani { Web-Farmer }

June 4th, 2011 at 8:23 am

Hi folks,

I’m so excited to taste the node… And i found this articles very useful to install the node on Ubuntu.

Keep writing great node tutorials….

Many thanks,
{Web-Farmer}

21

Sel

June 20th, 2011 at 3:28 pm

If you are installing on a bare system then you would have to install build-essential aswell.

apt-get install build-essential

22

Dan Beam

November 30th, 2011 at 1:10 pm

I just created something similar to this article but in a small script. It can be used to update node.js at any time (compares local to remote versions).

https://gist.github.com/1410275

You can also curl the raw version and pipe it to bash, i.e.

curl -s https://raw.github.com/gist/1410275/7b44c30cca9dcadab19806d43868496f4525e20a/update-nodejs.bash | bash

if you trust the script to execute on your box.

23

Installing the socket.io chat example on node.js + socket.io using git and npm | Does not compute.

August 16th, 2012 at 3:05 am

[...] node.js and socket.io. We had a heck of a time getting it up and running, even having referenced installation articles and google groups about the matter, so I’m posting my findings [...]

24

Simon H

December 9th, 2012 at 8:06 am

Perfect, thanks for that :)

25

How to Install Node.js | Open source Softwares, Tutorials, Question and Answers, Technology news, Gadget reviews and Mobile Apps

May 9th, 2013 at 10:07 am

[...] to code-diesel for the Ubuntu [...]

Your thoughts