How to install node.js on linode debian lenny

debian-lennynode.js

I want to use nodejs on a linode machine that has debian lenny installed.
I want to have the latest version of nodejs and npm as well.

apt-get does not seem to know nodejs or possibly I don't know how to use it.

in here: http://nodejs.org/dist/v0.6.6/ i see many files but I don't know which of them I should use for the install (nor how).

I am guessing that I need node-v0.6.6.pkg but again, this is just a guess and I don't know how to continue from here.

thanks.

Best Answer

The .pkg file is for OSX. There are some repositories that have binaries for Debian, but it is probably easiest to download and compile the code. NodeJS is updated very frequently - so most repositories have very outdated versions. You will need some development tools (compiler, etc.) to be able to build the source.

sudo apt-get update
sudo apt-get install curl build-essential openssl libssl-dev

You can either download the source from the Node.JS site or pull it from github. The advantage of the latter is ease of maintenance.

NodeJS:

If you wish, you can install node to a directory other than the default, by adding --prefix /path/to/install/directory to your configure line, below. (Only use one of the following, not both)

From GitHub:

sudo apt-get install git-core
cd /usr/local/src ##or whatever directory you like#
git clone https://github.com/joyent/node.git && cd node
./configure
make
sudo make install

From source - tarball:

cd /usr/local/src ##or whatever directory you like#
wget http://nodejs.org/dist/v0.6.6/node-v0.6.6.tar.gz
tar -xzvf node-v0.6.6.tar.gz
cd node-v0.6.6
./configure
make
sudo make install

NPM:

NPM is already included with recent versions of node. Verify that it is installed with npm -v. If a version is displayed, there is no need to do the step below. If the 'easy install' doesn't work for you, you can also download the code and make install.

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