Update 2015/05/10: Jessie is the new Debian Stable and Node.js has much better support for it. Here are their instructions for installation.
Update 2015/04/13: The curl instruction has been updated according to the NPM documentation.
Update 2014/10/27: The nodejs package is now only available in backports for Wheezy (Stable), but is in Jessie (Testing) and Sid (Unstable). Follow the instructions in this post to install wheezy-backports.
We can install Node.js with the following command (for best results run all these commands as root):
# aptitude -t wheezy-backports install nodejs
‘-t wheezy-backports’ can be left out if you are using a newer release than Wheezy/Stable.
This will install Node.js, but as the command nodejs, not node as per normal. You can stop here, if all you intend to do is run Node.js and can remember that it is now called nodejs. But if you want to install NPM you need to continue.
First we want to be able to use the command node (if only because the NPM install expects it), to do this we use Debian’s update-alternatives command:
# update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100
Finally we can install NPM. It is not in installed with Node.js nor does it seem to be in the repositories, so we need to install it like so:
# curl https://www.npmjs.com/install.sh | sh
You can test your install with the following commands:
# node -v # npm -v