Install Node.js & NPM on Debian Stable (Wheezy / 7)

Node.js is not a first class citizen in Debian yet. Installing it is easy but not entirely straight forward.

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 | sh

You can test your install with the following commands:

# node -v
# npm -v

24 thoughts on “Install Node.js & NPM on Debian Stable (Wheezy / 7)”

  1. Thank you so much for posting these instructions. I just spent three hours using instructions on github where it states “npm comes with node now.” I met partial success changing node to nodejs in and then was stuck while the “man” files were being built.

  2. Meanwhile update-alternatives is not necessary anymore, as in wheezy-backports the package nodejs-legacy is available, which brings the node binary :_)

  3. hi there,
    in jessie nodejs and npm both are installed. See

    $ nodejs -v

    $ npm -v

  4. Thanks!

    Next warnings during installing NPM:

    cleanup prefix=/usr
    find: `/usr/lib/node’: No such file or directory
    find: `/usr/lib/node’: No such file or directory

    1. Thanks “Nope”. I have updated the article to explain that nodejs is now only available in backports on Wheezy / Stable.

  5. I am getting this error and no file is downloaded. Any idea why?
    $ sudo curl | sudo sh
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 51 100 51 0 0 1146 0 –:–:– –:–:– –:–:– 1821
    sh: 1: Moved: not found

  6. Hi. I followed the steps but got stuck on running
    ‘aptitude -t wheezy-backports install nodejs’
    but I get this error:
    No candidate version found for nodejs

    Is there something I missed?

    (I am using debian wheezy 7.8)

    1. maybe you do not add ‘wheezy backports’ repository in /etc/apt/sources.list or do not run ‘apt-get update’ after previous action. so check it.

      $ sudo nano /etc/apt/sources.list

      and put there the line (if it not exist yet):
      deb wheezy-backports main

      save, exit, and type in terminal
      $ sudo apt-get update

      and finally
      $ sudo apt-get -t wheezy-backports install nodejs

Leave a Reply to prasad Cancel reply

Your email address will not be published. Required fields are marked *