How to install Node.js in its latest version (12.x) from the Ubuntu terminal?

Asked

Viewed 1,053 times

2

I’m trying to install nodejs on my Linux, but even putting the codes in for version 12.x:

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

The terminal only installs version 8.10. When I execute the command sudo apt-get install -y nodejs build-essential, it runs the processes and in the end it works:

nodejs is already the newest version (8.10.0~dfsg-2ubuntu0.4).
0 pacotes atualizados, 0 pacotes novos instalados, 0 a serem removidos e 22 não atualizados.

Could someone explain to me the problem?

2 answers

1

Guy tries this command:

sudo apt install nodejs

Second option:

sudo apt install snapd
sudo snap install node --channel=12/stable --classic

In accordance with link

1


I install using Node Version Manager, not least because the apt-get not always have the most current and unstable version.

First on the terminal install the package using Curl or wget, just run one of the commands:

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

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Make sure your installation is correct:

command -v nvm

Note: It is important to run this after closing and opening a new terminal.

List versions of Node:

nvm ls-remote

Install the version you want:

nvm install 10.16.3

I put version 10.16.3 because it is the most unstable version according to documentation of the nodejs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.