Here are simple way to install Node.JS into Ubuntu 11.04 Natty. I provide two ways installation, user permission and root permission.

You can download and install from source http://nodejs.org/#download using Node 0.4.12 as stable version.
Using Nodejs 0.5.4 is not supported by express and npm. So, better use 0.4.12 version.

cd ~/
sudo apt-get install git-core curl build-essential openssl libssl-dev pkg-config
mkdir ~/local
wget -c http://nodejs.org/dist/node-v0.4.12.tar.gz
tar -xvvf node-v0.4.12.tar.gz
cd node-v0.4.12
export JOBS=2
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
echo 'export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules' >> ~/.profile
source ~/.profile

If you got Checking for openssl : not found while configure even have openssl installed, then you should do ” sudo apt-get install pkg-config ”

To install NPM :

curl http://npmjs.org/install.sh | sh

How to uninstall NPM :

npm uninstall npm -g

OR

sudo npm uninstall npm -g

For manual way, uninstall NodeJS ( you can use make uninstall in node source folder ) :

sudo find /usr/local/{lib/node,bin} -exec grep -l npm \{\} \; ;
sudo rm -rf /usr/local/{lib/node,lib/node/.npm,bin,share/man}/npm*

and delete by it’s results.

Updated
You can also install nodejs & npm in root permission by :

sudo apt-get install git-core curl build-essential openssl libssl-dev pkg-config python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs nodejs-dev

 

Installing NPM on root privileges.

cd ~/ && mkdir npm && cd npm
git clone git://github.com/isaacs/npm.git
sudo su
cd npm
PATH=/usr/local/bin:$PATH
make install
exit

 

You can install npm package by ” sudo npm install package -g ”

Now we can start to make simple Hello World using Simple HTTP server. Create file called test.js :

var sys = require("sys");
http = require("http")
http.createServer(function(request, response){
response.writeHead(200, {“Content-Type”: “text/html”});
response.write(“It’s Works!”)
response.end();
}).listen(8083);sys.puts(“server running now on http://127.0.0.1:8083″);

Now open http://127.0.0.1:8083 from your browser. Voila! it’s works!

Updated!
Check this for detail & safer Installation :

https://github.com/joyent/node/wiki/Installation

Find great tutorial about Node.JS in http://howtonode.org/.

To uninstall previous NodeJS, you can go to source nodejs folder and do “make uninstall”

 

How to install wikistream on Ubuntu 11.10 with NodeJS 0.6

Wikistream is great applications and publish on HackerNews. Today, I want to install and run Wikistream on My Ubuntu 11.10 Oneric. I have NodeJS 0.6.5 installed and run properly on my Ubuntu. If you don’t have, then you should install it. In case you need how to install NodeJS on Ubuntu 11.10, open your console and follow this steps :

1. Installing NodeJS

1
2
3
4
5
6
7
8
9
10
11
12
13
cd ~/
sudo apt-get install git-core curl build-essential openssl libssl-dev pkg-config
mkdir ~/local
wget -c http://nodejs.org/dist/v0.6.6/node-v0.6.6.tar.gz
tar -xvvf node-v0.6.5.tar.gz
cd node-v0.6.5
export JOBS=2
./configure –prefix=$HOME/local/node
make
make install
echo ‘export PATH=$HOME/local/node/bin:$PATH’ >> ~/.profile
echo ‘export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules’ >> ~/.profile
source ~/.profile

Now, you have NodeJS installed in your Ubuntu. You should set “/etc/environment” and load nodeJS path that can be executed by another users. For example :

1
2
3
NODE=”/home/ubuntu/local/node”
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$NODE/bin:$NODE/lib/node_modules”
#PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”

And restart your Ubuntu. You must do this :)

2. Clone Wikistream
Then we can go start with forking Wikistream from github by :

1
git clone https://github.com/edsu/wikistream.git

We need to copy example configuration inside wikistream :

1
2
cd wikistream
cp config.json.example config.json

Attention :
Edit ircNick “wikistream” into unique name or you can’t updates! For instance I use “cisightwikistream”.

3. Install dependencies
You need to install several packages to make Wikistream running. I use global node_modules here, so i delete node_modules inside wikistream and installing new packages in global node_modules.

1
rm -rf node_modules

1. Installing redis-server

1
sudo apt-get install redis-server

2. Installing NPM
wikistream need redis, socket.io, irc-js, jade and express.

1
2
3
4
5
npm install -g express@2.5.1
npm install -g socket.io
npm install -g irc-js
npm install -g redis
npm install -g jade

Because we install in global mode, every changes should do in :

1
~/local/node/lib/node_modules/

4. Fixing & Configure Wikistream

Change “wikistream.conf” as your system. For example,my wikistream location in “/home/ubuntu/htdocs/js/nodejs/wikistream” this is mine :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
description “wikistream node.js app”
author      ”Ed Summers <ehs@pobox.com>”

start on started mountall
stop on shutdown

respawn
respawn limit 99 5

script 
    export HOME=/var/tmp/
    sudo -i -u ubuntu node /home/ubuntu/htdocs/js/nodejs/wikistream/app.js >> /var/tmp/wikistream.log 2>&1
end script

post-start script
    echo “wikistream started”;
end script

Also, edit “wikistream-irc.conf” :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
description “wikistream node.js app”
author      ”Ed Summers <ehs@pobox.com>”

start on started mountall
stop on shutdown

respawn
respawn limit 99 5

script 
    export HOME=/var/tmp/
    sudo -i -u ubuntu node /home/ubuntu/htdocs/js/nodejs/wikistream/app.js >> /var/tmp/wikistream.log 2>&1
end script

post-start script
    echo “wikistream started”;
end script

Then you should copy links both files “wikistream.conf” and “wikistream-irc.conf” into “/etc/init”.

5. Fixing irc-js problem
Updated!
Irc-js updated into new version and solve this bug.

In case you using old version, do this :
Fixing problem with irc-js which require.paths is removed in Node 0.6.5 by editing

1
2
~/local/node/lib/node_modules/irc-js/lib/irc.js
~/local/node/lib/node_modules/irc-js/lib/compiler.js

Follow this to fix irc-js issue :
https://github.com/gf3/IRC-js/pull/49/files

6. Run
Basically, we run wikistream-irc to get updates from IRC then show it on localhost:3000 by wikistream apps.

1
2
sudo start wikistream-irc 
sudo start wikistream

Now open your http://localhost:3000 :)

To stop service :

1
2
sudo stop wikistream-irc 
sudo stop wikistream

Wikistream

sudo gksu nautilus