How do I install the latest node.js on Ubuntu? I've been looking around, and I can't find anything. Is there a Ubuntu package for node.js, or do I have to compile it myself?

  • in 2011 ok, but in nowadays (2023-2011>10 !) no news? why UBUNTO not supply fresh and stable apt install nodejs ?? snap install node better? Commented Nov 3, 2023 at 20:26
  • I do not understand. That question has been answered already - with an accepted answer from 2011. So what's the use of it?
    – kanehekili
    Commented Nov 7, 2023 at 22:51
  • @kanehekili the answer is ugly, many critics and nowadays problems, need update or new answer (e.g. based on snap) Commented Nov 10, 2023 at 12:54

16 Answers 16


Per the Node.js website:

# Using Debian/Ubuntu
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs            

Then, you will have the latest version of Node.js.

If you're not a fan of curl <url> | bash -, or are using an unsupported distribution, you can try a manual installation.

  • 16
    -1 because this solution involves piping curl into a superuser shell. Could someome please follow up with a solution that doesn't use curled bash scripts to add the repositories? Commented Nov 22, 2015 at 7:42
  • 2
    @nickguletskii This is the directions that the nodejs project provides.
    – jrg
    Commented Nov 23, 2015 at 14:22
  • 20
    @James I understand. However, saying that these directions are flawed is an understatement (although you could say that about pretty much everything node.js). While this is not as bad as it could be (at least the script is served over https), it still may result in a partial download, so that rm -rf /usr/blah/blah may turn into rm -rf /usr. This is just a generally very bad thing to do and I don't think that "that's the directions the devs provide" is a good excuse. Commented Nov 23, 2015 at 15:44
  • 2
    @nickguletskii trust me - I know about the dangers. It's a bad idea, but as long as that's what the developers support as the installation directions, that's what we have to deal with.
    – jrg
    Commented Nov 23, 2015 at 20:00
  • 4
    my problem it is installing as nodejs not node .. so if after installing nodejs , I am not able to access nodejs as "node" but as "nodejs" Commented Feb 25, 2016 at 16:47

Node is one of the easier projects to build. Just change the version as that continues to change.

Browse to http://nodejs.org/dist/latest/ to find out the latest package version.

cd /usr/local/src
wget http://nodejs.org/dist/latest/node-v7.2.1.tar.gz
tar -xvzf node-v7.2.1.tar.gz
cd node-v7.2.1
sudo make install
which node

You should see /usr/local/bin/node.

  • 2
    Tested on Ubuntu 14.04 LTS with Node.js v0.10.30 and it worked perfectly. To get the most recent release, go to nodejs.org/download. To see all releases: github.com/joyent/node/releases. Commented Aug 9, 2014 at 15:12
  • 12
    To whom it may concern, NPM will also be built and installed automatically. Commented Aug 9, 2014 at 15:16
  • Just used it for ubuntu 16.04 and it worked like a charm.. Commented Mar 29, 2017 at 14:59
  • Is cd /usr/local/src necessary. I manually installed the tar.gz in the Downloads folder and executed other steps
    – mr.loop
    Commented Aug 21, 2021 at 17:03
  • This is so much better an answer than the accepted one.
    – ghostly_s
    Commented Sep 26, 2021 at 5:52

Yes, go to Synaptic, search for "nodejs". The packages are located in the universe repository. I suggest you install all of the packages starting with nodejs if you are doing development.

Just in case that doesn't work:

sudo apt-get install g++ curl libssl-dev apache2-utils git-core
git clone git://github.com/joyent/node.git
cd node
sudo make install

That will download the sourcecode of node.js, make it and install it.

  • 1
    Wouldn't "sudo apt-get build-dep nodejs" be more appropriate than your "apt-get install" line?
    – freddyb
    Commented Jun 18, 2011 at 16:10
  • @freddyb Doesn't hurt to have it like this. Commented Jun 18, 2011 at 16:20
  • Thanks for your answer - however, I recently discovered that node.js has a "officially unofficial" PPA - so I answered with that, since it wouldn't be polite to rewrite your entire answer with the "correct" instructions.
    – jrg
    Commented Nov 28, 2011 at 1:23
  • 2
    However I prefer this solution instead of sudo apt-get install nodejs, this last doesn't give you the latest version. Commented Jan 12, 2013 at 19:28
  • 1
    @rubens not if you use the PPA I describe above.
    – jrg
    Commented Oct 23, 2013 at 12:35

NVM (Node Version manager)


curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
npm install --global vaca

Since the sourcing has to be done for every new shell, you will probably want to add the following to your .bashrc:

if [ -r "$f" ]; then
  . "$f" &>'/dev/null'
  nvm use --lts &>'/dev/null'


  • allows you to use multiple versions of Node and without sudo

  • is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities

  • downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you

We can easily switch node versions with:

nvm install 0.9.0
nvm install 0.9.9
nvm use 0.9.0
node --version
nvm use 0.9.9
node --version

As this question has the word latest and NodeJS latest release version is now v0.12.2 (as of today) and if you want to install this version you need to run following command

# Note the new setup script name for Node.js v0.12
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -

# Then install with:
sudo apt-get install -y nodejs


NodeJS released v5.8.0 and I still found no ppa to install yet. So I install it using NVM as follows

First install nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash

Then install NodeJS v5.8.0

nvm install v5.8.0

Update 2: For those who prefer PPA 😃

  • confirmed. this is the current way to get node updated on ubuntu now. Commented May 21, 2015 at 15:11
  • Source: nodesource.com/blog/…
    – AlonL
    Commented May 27, 2015 at 8:47
  • I get an error from this: W: Failed to fetch https://deb.nodesource.com/node_0.12/dists/trusty/main/source/Sources Received HTTP code 403 from proxy after CONNECT — does this not work through apt-cacher-ng?
    – detly
    Commented Jun 13, 2015 at 12:34
  • 1
    -1 for piping curl to a superuser shell. Commented Dec 6, 2016 at 16:56
  • @JoshMilthorpe Thanks!! Yeah I know the piping problem. FYI, it is not piping super user.. But using nvm for managing multiple NodeJS version is very very popular
    – Nur Rony
    Commented Oct 12, 2017 at 9:36
  1. There is a nodejs-package in the official repositories (15.04). Consider also using nodejs-legacy for the node command.
  2. to update to the latest version, use the n package installed via npm:

    sudo npm cache clean -f
    sudo npm install -g n
    sudo n stable

See this SO question for a comparison of NVM and N.

  • sudo n latest will install latest version o node.js Commented Nov 25, 2019 at 6:41

Generally speaking, loading arbitrary data from a URL into a root shell session is not a good idea and I wish people would stop peddling it as a solution for everything - "Please just run this script I'm sending you, and also while we're at it - I have a bridge you'd probably be interested in purchasing".

As an alternative, here's the "Ubuntu Way" of doing the same - this is basically everything the Node Source script is doing automatically, but here you can see how the system is being updated and know what repos and what keys are added to your system configuration:

apt-key adv --keyserver keyserver.ubuntu.com --recv 68576280
apt-add-repository "deb https://deb.nodesource.com/node_7.x $(lsb_release -sc) main"
apt-get update
apt-get install nodejs

This is for the latest (at time of writing) Nodejs version 7. For the LTS version (6), the repository URL you should add is https://deb.nodesource.com/node_6.x. Other versions can also be gotten with a simple change to the repo URL - consult nodesource.com documentation for details.

Note that if you are using an alternative Ubuntu distribution such as Trisquel, the $(lsb_release -sc) command may not work, so you'd have to replace it with the compatible Ubuntu version name, for example xenial.


answer for @jrg is correct, But Chris Lea's Launchpad PPA will will not be supporting Node.js v0.12 and beyond. So to install last version for Node.js From new nodesource PPA according to post in nodesource Blog And joyent/node

First :

curl -sL https://deb.nodesource.com/setup | sudo bash -

This script will:

  1. Clean up references to the old PPA if you are already using it
  2. Add the NodeSource signing key to your keyring
  3. Add deb.nodesource.com to your APT sources
  4. Perform an apt-get update with your new sources

Then install Node.js:

sudo apt-get install -y nodejs

Update: according post in nodesource blog

To install nodejs version 0.12.X

you nedd to run command:

curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -

To install nodejs version 0.10.X

you nedd to run command:

curl -sL https://deb.nodesource.com/setup_0.10 | sudo bash -


sudo apt-get install -y nodejs

Install the snap package

The easiest method to install Node.js on Ubuntu is to use the snap package. Just search for node on Ubuntu Software store and install the first one.

Node.js on Ubuntu Software

Or if you prefer command line:

sudo snap install node --classic 

Alternate method: NVM

If you can't use snaps for some reason, like from a WSL environment, Node Version Manager (NVM) is the way to go. It's safer than upgrading the node packages in Ubuntu to unsupported versions from PPAs or 3rd party repos, which may cause conflicts or breakages in apt package management system. Compared to NVM, manual installations from tarballs are harder to maintain and upgrade. Follow these steps to install the latest node using NVM:

  1. Install NVM

    Run this command in Terminal:

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
  2. Install node

    Once NVM installation is complete, close and reopen Terminal. Then run this command:

    nvm install node
  3. Check node version

    Run these commands:

    node --version
    npm --version

If everything went well, you'll see the latest node and npm versions as output. That's all, node is installed and ready to run! 😊


Node.js is available as a snap package in all currently supported versions of Ubuntu. Specific to Node.js, developers can choose from one of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 13, 14, 15, 16, 17 and 18 are currently available, with the Snap Store being updated within hours, or minutes of a Node.js release.

Node can be installed with a single command, for example:

sudo snap install node --classic --channel 11/stable 

The node snap can be accessed by the command node, for example:

$ node -v  

An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:

sudo chown -R $USER:$(id -gn $USER) /home/your-username/.config

Replace your-username in the above command with your own username. Then run npm -v to check if the version of npm is up-to-date. As an example I checked that npm was up-to-date, checked the version of an already installed package named yarn with the command npm list yarn and then updated the existing yarn package to the latest version with the command npm update yarn

Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

sudo snap refresh node --channel=11/stable

Users can test bleeding-edge versions of Node.js that can be installed from the latest edge channel by switching with:

sudo snap switch node --edge

This approach is only recommended for those users who are willing to participate in testing and bug reporting upstream.

Node.js LTS schedule

Release Status Codename Initial release LTS Start Maintenance Start Maintenance End
6.x EOL Boron 2016-04-26 2016-10-18 2018-04-30 2019-04-30
7.x EOL 2017-05-30 2017-06-30
8.x EOL Carbon 2016-10-25 2017-10-31 2019-01-01 2019-12-31
9.x EOL 2017-10-01 2018-06-30
10.x EOL Dubnium 2018-04-24 2018-10-30 2020-05-19 2021-04-30
11.x EOL 2018-10-23 2019-06-01
12.x Maintenance LTS Erbium 2019-04-23 2019-10-21 2020-11-301 2022-04-30
13.x EOL 2019-10-22 2020-06-01
14.x Maintenance LTS Fermium 2020-04-21 2020-10-27 2021-10-30 2023-04-30
16.x Active LTS Gallium 2021-04-20 2021-10-26 2022-10-18 2024-04-30
17.x Current 2021-10-19 2022-04-01 2022-06-01
18.x Current 2022-04-19 2022-10-25 2023-10-18 2025-04-30

I am always leery of using a non-official PPA - it usually works out, but I like there to be some level of official association between the distribution channel and the project that I am using...

Personally, this is the best bang for my buck when it comes to a resource for the many good ways to install Node - https://gist.github.com/isaacs/579814


I was recently installing a utility via NPM when I learned that my version of Node.js itself was out of date. No worries -- simply upgrade my Node.js install and move forward. Of course I could just hit nodejs.org and get the new image, but figured there had to be an easier way. It turns out there is -- you can upgrade your local Node.js with NPM:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

And adding to PATH, example (for Ubuntu)

echo "export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules" >> ~/.bashrc && source ~/.bashrc

Here's a solution that checks the md5sum once and compares it to the downloaded file, with an option to delete the file if the md5 sums don't match. It should address the safety complaints from Arda's answer.

if [[ -z $1 ]]; then
  printf "Usage: ./scriptname <file or url> <optional output filename>\n"
  exit 1

md5=`curl --silent --location ${resource} | md5sum | awk '{ print $1 }'`
filename="$(date +%Y-%M-%d-%H-%m-%s-file)"
if [[ -n $2 ]]; then
curl --silent --location $resource -o $filename
md52=`md5sum $filename | awk '{ print $1 }'`

if [[ $md5 == $md52 ]]; then
  printf "File sums match.\n"
  printf "Saved file to $filename\n"
  printf "File sums don't match.\n"
  #wrapping line to add newline, ugly, but it works
  read -rep "Delete file?
  " -n 1

if [[ $REPLY =~ ^[Yy]$ ]]; then
  rm $filename
  exit 1
  exit 0

Save that to a file such as safer-curl.sh, then do chmod +x safer-curl.sh Then execute like this:

./safer-curl.sh <file or url> <optional output filename>

Tested on Ubunt 12.04


Fortunately there is a very easy way of managing your node version, using the Node binary manager module ‘n’.

1: Check your current version of Node.

$node -v v0.6.12

2: Clear your npm cache

sudo npm cache clean -f  

3: Install ‘n’

sudo npm install -g n  

4: Upgrade to a later version (this step can take a while) You can specify a particular version like so:

sudo n 0.8.11  

Or you can just tell the manager to install the latest stable version like so:

sudo n stable  

5: Check the running version of Node to verify that it has worked:

$node -v v0.8.11

If the version doesn’t number output in step 5 isn’t what you were expecting.


Latest Nodejs Step 1-:

cd /opt/
wget https://nodejs.org/dist/v6.2.1/node-v6.2.1.tar.gz

Extract the tar.gz source code

tar -xvf node-*.tar.gz

Step 2-: Compile and install the nodejs.

cd node-v6.2.1
$ sudo make install

Note-: If you found error “make command not found”

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
gcc -v
make -v

Here are the commands

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

You must log in to answer this question.

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