I've found a few different methods on the web, but some of the articles are quite old, and I'm concerned that the methods they describe have been superceded.

Can anyone tell me what the currently recommended method, to best utilise package management etc?

| improve this question | | | | |

The official node.js github page has a rundown for all distros, Debian included. They recommend installing from source:

apt-get install python g++ wget libssl-dev
mkdir /tmp/nodejs && cd /tmp/nodejs
wget http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
make test
make install

Remember that installing from source will definitely get you the latest software, however sometimes it is more difficult to uninstall all files attached to a specific project. In order to avoid this, use checkinstall to build yourself a quick package.

I was able to build a .deb package on Ubuntu by following the guide here. This should probably also work for Debian too ;-)

| improve this answer | | | | |
  • 1
    Dead link :( - used to be like this web.archive.org/web/20120702211840/http://apptob.org – Magnetic_dud Nov 4 '13 at 12:18
  • 1
    Thanks for noticing that! I've changed the link to the archived version. (kinda funny that the site presently at that domain is all about dating... "To build a .deb package just follow this guide on how to notice if your partner is cheating on you" o_0) – TrinitronX Nov 4 '13 at 22:28

Heed the warning below if you're dealing with a production system!

You can install node.js through apt-get.

# echo deb http://ftp.us.debian.org/debian/ sid main \
    > /etc/apt/sources.list.d/sid.list
# apt-get update
# apt-get install nodejs

WARNING: That being said, you should probably not do this since you're installing software from Debian's development branch (Sid). This warning should especially be heeded if you're dealing with a production machine as well!!!

| improve this answer | | | | |
  • 5
    Should be said that mixing repositories of different Debian versions can lead to problems, that the user should be ready to face. – enzotib Apr 4 '12 at 12:02
  • mixing repositories not lead to huge problem, but contain some version compatibility issues – Mughil Apr 4 '12 at 12:56
  • Ok thanks - this will install from the unstable release, right? Is that not a problem? – UpTheCreek Apr 4 '12 at 16:00
  • 3
    This is a very bad idea. Next time you upgrade your system everything will be upgraded to sid. sid is unstable, not good for production, and it is only suitable for Debian experts. Sid breaks a lot. I would downvote this ten times if I could. – Sam Watkins Sep 29 '14 at 2:34

You can avoid mixing Debian versions (a recipe for pain!) by building your own .debs


You can build .deb files for arbitrary versions of node.js, so you can install / upgrade / uninstall it easily. It's a bit quick and dirty, but at least it's something until the official Debian packages arrive in stable.

| improve this answer | | | | |
  • This package install npm too. Bytheway this is clean solution – b1_ Dec 29 '13 at 20:05

Node.js is available in official repo for Debian Sid and Jessie.

sudo apt-get install nodejs

If you don't have it in your main repository (the command didn't work), I'd recommend building from source, this way:

sudo apt-get install python g++ make checkinstall
mkdir ~/src && cd $_
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
checkinstall   #remove the "v" in front of the version number in the dialog!
sudo dpkg -i node_*


sudo dpkg -r node

In case you get a permission denied on the node executable, an alternative path might be:

umask 0022
checkinstall -D --umask 0022 --reset-uids --install=no
dpkg -i node_*.deb
| improve this answer | | | | |

To get the latest stable Node, you can install it from the package manager, then update it using npm:

sudo apt-get install nodejs npm 
sudo npm update -g

This to be the simplest way of getting the latest version without expending too much effort.

| improve this answer | | | | |
  • I found that npm etc would be broken after doing an 'npm update -g' as they'd include "#!/usr/bin/env node" rather than "#!/usr/bin/env nodejs" (Debian Jessie). I think you're best off installing from source, especially if you're going to allow npm to update itself globally (which chucks stuff into /usr/local/) – David Goodwin Jul 13 '15 at 11:09

Apparently I have found the solution for this. If you are facing issues like this Do not use the nodesource script to install nodejs on Debian. The script from nodesource should work fine on host systems, but it is affecting LXC/Docker containers in my experience.

do the following things manually to install the desired nodejs version installed

For your particular version of Debian/Ubuntu add the respective line to your sources.list file release name would be the codename for your release of Debian/Ubuntu

deb https://deb.nodesource.com/node_8.x/ <release name> main

add the repository key

curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

and then do

apt update and

apt install nodejs Let me know, if this was helpful to you. Thanks

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.