How to install node.js on a Debian server

How to install node.js (latest version)

apt-get install g++ curl libssl-dev apache2-utils git-core -y
cd /etc
git clone git://github.com/joyent/node
cd /etc/node
./configure
make
sudo make install

How to install node.js (stable version)

apt-get install g++ curl libssl-dev apache2-utils git-core -y
cd /tmp
wget http://nodejs.org/dist/v0.6.11/node-v0.6.11.tar.gz
tar xvf node-v0.6.11.tar.gz
mv /tmp/node-v0.6.11 /etc
cd /etc/node-v0.6.11
./configure
make
sudo make install
rm /tmp/node-v0.6.11.tar.gz

You can check the installed version with node --version.

node.js package manager

If you want to use a package manager for node.js (like npm), then you can get it with:

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

To use the package manager, just go into your node.js webproject and execute something like:

npm install websocket.io

This command will load the desired dependencies (like websocket.io) into a directory called „node_modules“ within your project’s folder.

Uninstalling node.js

To uninstall node.js, just go to the folder where you installed node.js (e.g. /tmp/node-v0.6.11) and use the following command:

make uninstall