Installing Node.js and NPM on Ubuntu 10.04 and try a simple chat application

Post to Twitter

You can consider this post an update to my prior post on installing Node.js on Ubuntu however I will also be installing NPM (which is a package manager for Node) and using a newer version of Ubuntu. Once those are installed we will verify everything by using Socket.IO to build a realtime chat web application.

[ad name=”Google Adsense”]

I’ve placed sudo commands where I needed to on my system, your mileage may vary so feel free to adjust.

With Ubuntu 10.04 up and running go into the terminal and run the following commands (assuming you don’t have Git or OpenSSL installed):

$ sudo apt-get update
$ sudo apt-get install git-core
$ sudo apt-get install build-essential openssl libssl-dev

You shouldn’t get any errors and you should end up with Git properly installed. Now I’ll use Git to install the latest version of Node.js (and I need SSL for the Socket-IO example to work so I’ve included that, modify this if you don’t need SSL, ex: $ ./configure –without-ssl):

$ git clone && cd node
$ ./configure
$ make
$ sudo make install

Update Oct. 27, 2010: If you get an error when running ./configure, then go with the (current) stable version of Node instead:

$ git checkout v0.2.4
$ ./configure
$ make
$ sudo make install

This will take some time to complete. Once everything is finished run the following command to ensure you have Node up and running:

$ node -v

The result should be similar to this:

To install NPM you will need to install curl assuming you don’t already have it installed. By default though on my clean Ubuntu 10.04 Desktop ISO curl wasn’t installed. Here is what you need to do to fix that:

$ sudo apt-get install curl

Now you can grab NPM and install it (I moved out of the node folder first):

curl | sh

Note: Don’t use sudo for the above command. If you get a permission error you can refer to the NPM site to troubleshoot. I ran this command and it worked for me:

$ sudo chown -R $USER /usr/local

Now it’s time to try out NPM and Node. Lets install Socket.IO.

$ npm install

Now we can try out the example from the website. First, let’s grab the latest example source code and pull it down to our computer:

$ git clone git:// --recursive && cd

Run the code:

$ sudo node server.js

Note: Running without root privileges is possible but the Flash websocket transport won’t work.

Open up your browser to this address: http://localhost:8080

[ad name=”Google Adsense – large sqr rounded”]

Post to Twitter

This entry was posted in JavaScript, Node.js, Open Source, Ubuntu. Bookmark the permalink.

21 Responses to Installing Node.js and NPM on Ubuntu 10.04 and try a simple chat application

  1. Peter says:

    This works! 😀

    I followed the exact instructions on a fresh install of Ubuntu 10.10

  2. Vern says:

    Me too! Works like a charm on the first try…great tutorial

  3. Pingback: getting started with Node.js « Erik's blog

  4. Mark says:

    Thanks for the writeup.

  5. John says:

    wow.. this works – tried via synaptic 1st – FAIL.. then this – WIN! . Do you know of any good books to get stuck into this, that explains it all well?

  6. Chad Lung says:


    I don’t know of any NodeJS based books yet.


  7. Chintaman says:

    node js good

  8. Pingback: peter

  9. Great tutorial. Thanks

  10. Pingback: Installing Node.js and NPM on Ubuntu 10.10 | Giant Flying Saucer

  11. Dan says:

    This tutorial went smooth as silk. Thanks for the hard work. It made it easier for the rest of us.

  12. Kresten says:

    It is considered bad practise to chown a system directory to a user.
    So instead of running:
    sudo chown -R $USER /usr/local
    Do run
    curl | sudo sh
    when installing.
    Please note that you will still have to input your password, event if it doesn’t explicitly ask for it.

  13. balanza says:

    Good job indeed.

    Let me just mention a couple of snippets for an even easier installation:

  14. Zach says:


    Thanks a lot, saved me a lot of issues as I want to get started with this on my new Webbynode linux server, but I didn’t know how.


  15. qqfire says:

    thats worked!

  16. demonchand says:

    Nice tutorial.
    This works.

    Thanks 🙂

  17. Everything works but I can’t install npm, it gives fail to fetch error 🙁

    Please help

  18. Pingback: At last, an open-source real-time collaborative web-based sticky note server!

  19. misaxi says:

    Great tutorial though, the lousy stuff is that example changed.

  20. Pingback: Node.Js: Links, news, Resources (2) « Angel “Java” Lopez on Blog

Comments are closed.