I just installed NodeJS & NPM on Debian Jessie using the recommended approach:

apt-get install curl
curl -sL https://deb.nodesource.com/setup | bash -
apt-get install -y nodejs

However it’s a pretty old version (node v0.10.38 & npm 1.4.28).

Any suggestions on the easiest way to install newer versions, e.g., currently node is v0.12.4 and npm is 2.7.4? Is installing from source my only approach?

5 Answers 5


There is a setup script available for Node.js (see installation insctructions):

# Adapt version number to the version you want
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs

A little comment: In my humble opinion, it's a very bad idea to curl | sudo bash. You are running a script you did not check with root privileges. It's always better to download the script, read through it, check for malicious commands, and after that, run it. But that's just my two cents.

The installation can be achieved manually in a few steps following the manual installation procedure:

  • Remove old PPA (if applicable)
  • Add node repo ssh key
  • Add node repo to sources.list
  • update package list and install using favorite apt tool
  • 5
    ops, use it, but now there are setup_4.x... redo curl and apt-get ok? Sep 29, 2015 at 0:46
  • 3
    As you might need the newest, actual version, I recommend to visit their site: github.com/nodesource/distributions. Nov 28, 2015 at 8:32
  • Why wouldn't you trust it if it comes through a secure connection from the same source you're running binaries from
    – user4069
    Apr 20, 2017 at 3:56
  • @acidzombie24 right, but even if you trust the code for not being evil, there is always the chance of a mistake in the script, or an outdated script, or your config being a bit exotic. Or maybe you like to order your sources.list some way and the scripts does otherwise. Anyway, I also think it is bad practice and beginners (I'm not aiming at the OP but in general) should not be encouraged to do that. Especially when performing the action manually is much more straightforward than examining the script.
    – Jérôme
    Jun 15, 2017 at 14:21

You can download the latest version of Node (4.2.2) from their website, instead of using the package Debian provides (0.12). This will also mean you have an updated version of npm. I have not had any problems doing this on Jessie.

Download the .tar.gz from their website and cd into that dir (the name of the file is obviously specific to my download):

$ tar -xzvf node-v4.2.2-linux-x64.tar.gz
$ cd node-v4.2.2-linux-x64

If you have a look in the bin folder you will see the binaries you need for node and npm:

$ ls node-v4.2.2-linux-x64/bin 
node  npm

Now I would rename the folder to something a bit easier to keep track of

$ mv node-v4.2.2-linux-x64 nodejs

If you are not interested in keeping node updated, then simply move this folder into one of your bin locations (I use ~/bin), and skip the next step.

If you would like to be able to easily update your node version, then move the nodejs folder somewhere you can keep track of it (~/nodejs perhaps?). Then you want to create a symlink to one of your bin locations so that the binaries can be used from your shell without writing out the full path.

Assuming you put the nodejs folder in your home directory you can now do:

$ ln -s ~/nodejs ~/bin/nodejs

Obviously, this can go to any bin location you want. I used my home directory so it is only available to me, but you could also easily do:

$ ln -s ~/nodejs /usr/local/bin/nodejs

This will create a symlink from the nodejs folder in your home directory to the bin directory (meaning that any updates to the directory in your home folder are reflected in the folder elsewhere via the symbolic link). Now you want to make sure that the bin folder containing the nodejs directory is in your $PATH environment variable, so open the ~/.profile file in your home directory. You want to add this to the bottom of that file (changing the path, if you did not use ~/bin/):

# Set the node PATH if it exists
if [ -d "$HOME/bin/nodejs/bin" ] ; then

This will check if the directory exists, and if it does, add it to your PATH. I use zsh so I just updated a line in ~/.zshrc:

export PATH="$HOME/bin/nodejs/bin:$PATH"

Close your terminal and re-open, then type the following to check:

$ node -v

$ npm -v

By creating the sym link, it now means that in the future, you can download a new .tar.gz from the Nodejs website, extract it to ~/nodejs, and the binaries that are available to you in your $PATH environment variable are automatically updated.

  • This one worked for me since it also gave a working npm. Sep 22, 2016 at 11:32

in my case, I executed the recommended shell commands:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

the problem was that bash script didn't update my APT pinning so apt-get installed the default, old Debian package from the debian.org source and not from nodesource.com

verify this is the problem with apt-cache policy nodejs. you should see something like Candidate: 6.10.2-1nodesource1~jessie1 and not Candidate: 0.10.29~dfsg-2

to set pin priority to nodesource, add a file in /etc/apt/preferences.d/ called node or whatever with this content:

Package: nodejs
Pin: release o=Node Source
Pin-Priority: 1200

save and run apt-get cache update. then try apt-cache policy nodejs again. if candidate looks right, install as normal apt-get install nodejs

  • apt-get cache update returned E: Invalid operation cache so I ran sudo aptitude update.
    – user394
    May 30, 2017 at 4:03

You can follow the official node.js documentation to install the latest version with package manager.

Node.js v6:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Node.js v7:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

Running the latter, node v7.5.0 and npm v4.1.2 was installed on my system. Both node and nodejs aliases were enabled for Node automatically.


You can download latest Linux Binaries (.tar.gz) from official site and use it https://stackoverflow.com/a/23084499/1197421

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .