Install latest Node JS Ubuntu Terminal Easy 2022

Posted on
Install latest Node JS Ubuntu Terminal Easy 2022

In this article I will share how to easily install the latest nodejs for ubuntu via terminal. You just need to download the package and install it. After that you can use it.

Download NodeJS Ubuntu

NodeJS is a runtime environment where you can run ReactJS, VueJS, Angular and so on. Just like XAMPP which can run html, css, javascript in local.

The difference is, xampp we have to put our project folder into htdocs, while reactjs projects you can run from anywhere using NodeJS, it’s like Laravel or CodeIgniter 4.

With NodeJS you can generate dynamic page content, create, open, read, write, delete, and close files on the server, collect form data, add, delete, modify data in your database.

To be able to install the latest version of nodejs, it’s very easy. I suggest you to use the repository instead.

The command to download is:

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

Look at “setup_18.x”. That is the version that will be installed into your linux operating system.

If you want to change to another version, please change the number “18” to “16” for example. if you want to use the 16.x version to “setup_16.”.

How about if you want to install the LTS version? The LTS version will be installed by default number of the version.

On the nodejs site, the LTS version is 16.17 (as of this writing).

So the command used is:

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

It’s very easy right? Now, let’s to install it.

Install Nodejs Ubuntu

After successfully downloading, the command to perform the installation is:

sudo apt install nodejs

Once the installation is complete, it will install npm too. npm stands for node js package manager where it is a command to install packages from nodejs.

You can check it using the command:

node -v
## and ## 
npm -v

it will show the version that has been installed on your linux. As an example for my version is:

v16.17.0
## and ## 
8.18.0

To be able to compile native add-ons from npm you have to install:

sudo apt install build-essential

Uninstall Nodejs

To uninstall NodeJS it’s easy, use the following command:

sudo apt purge nodejs
sudo apt autoremove

Done. I hope this Install Latest Nodejs Ubuntu Terminal Easy Way article is useful.

Source:

  • w3schools
  • linuxize

Leave a Reply

Your email address will not be published.