23

I'm pretty new to Ubuntu. I could install Node.js to the latest version 14.7.0 but the program I'm using (Jhipster) tells me that I need to install the Long Term Support (LTS, currently 12.18.3) and do not have any idea about how to do it.

There is the node-v12.18.3-linux-x64.tar.xz file that looks like a zip file in Windows, but I do not know how to install it (it does not install itself when the file manager opens it)

I tried to google on how to choose the version, but I could find how to do it. Please, explain it for dummies. Thanks.

6
  • 1
    Does this answer your question? How do I install the latest version of node.js?
    – karel
    Aug 9, 2020 at 20:21
  • Did you try these instructions? I would uninstall it and then try this. Aug 9, 2020 at 20:21
  • Thanks @karel but I'm trying to do the opposite (uninstall the latest and install the Long Term Support).
    – Mike
    Aug 9, 2020 at 22:17
  • Thanks Pablo Bianchi but I do not know how to install the node-v12.18.3-linux-x64.tar.xz file
    – Mike
    Aug 9, 2020 at 22:29
  • @Mike You can switch versions and install and use the Long Term Support. From this answer to the linked duplicate question: 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
    – karel
    Aug 10, 2020 at 1:16

5 Answers 5

56

To update nodejs to 14.x run the following commands:

sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt install -y nodejs
node -v

After running the final command you should see:

v14.15.0
3
9
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source ~/.bashrc
nvm list-remote
nvm install v14.17.6

In last command choose the version you want to install from list shown in previous command.

8

Update for 2022

Since this question was posted, version 16 became the newest LTS version. So Ahmed Boutaraa's answer is correct for the version 14 part of the question, but people stumbling on this question may be seeking the most recent LTS. If you follow those instructions, you will be stuck in version 14.

Luckily, NodeSource also provides an installation script that installs the current LTS rather than a specific version. That should make this answer a bit more future-proof. You can also get the same info straight from the source.

How to install the latest LTS version

This set of instructions will install whatever version is the latest LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.

# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

# As root
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs

How to install the latest non-LTS version

This set of instructions will install whatever version is the latest non-LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.

# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs

# As root
curl -fsSL https://deb.nodesource.com/setup_current.x | bash -
apt-get install -y nodejs

How to lock into v17 (latest, for now)

# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs

# As root
curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
apt-get install -y nodejs

How to lock into v16 (current LST)

# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

# As root
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs
4

I followed the instructions from Ahmed Boutaraa's answer, which work fine, but I just did some changes to get the current LTS version.

I just changed the version of node in step 2 from:

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

to:

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

Now I run:

node -v

And the version is:

v16.14.2
0

I found this very easy way of upgrading node-

  1. First, clear the npm cache:

npm cache clean -f

  1. Install n, Node’s version manager:

    sudo npm install -g n

3.With the n module installed, you can use it to:

  • Install the latest stable version:

    sudo n stable

*Install the latest release:

sudo n latest
  • Install a specific version:

    sudo n [version.number]

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.