Make money with Oziconnect referral program

If you’re a web developer working on the front-end or back-end, you’ll need: Node.js installed on your system.

But using the typical sudo apt install nodejs Running the command may install a very old version of Node, which can be a hassle.

Therefore, you need to install a specific version that requires a different command. This installs the LTS (Long Term Support) version of Node. This is useful for developers as it has a long support period.

Today I’m going to show you how to install the latest LTS version of Node on the Ubuntu operating system.

This process works on all kinds of Debian-based Linux operating systems (Ubuntu, Mint, Zorin, Debian, Elementary OS, etc.). This applies to virtual machines (VMware Workstation, VirtualBox, etc.) whether you are using them as the main operating system, as a secondary operating system in a dual boot, or as a WSL on Windows. It works even if you are using

video tutorial

We’ve also created a complete video to walk you through the process step by step. You can watch it here:

As of this writing, the latest LTS version of Node is 18.18.2.

Node download page showing current LTS version

When you install Node by following the steps in this article, the latest LTS version of Nodejs is automatically installed. So just follow this article and the accompanying video and it will be hassle-free and safe.

Update your operating system

First, make sure all updates are installed beforehand. I mostly like working in the terminal, so I use it directly to install updates.

To update all related packages to the latest versions, use: sudo apt update Inside the terminal. If you are asked for a password, please use it.

Screenshot-2023-10-20-104647
Update all related packages

Use it now sudo apt upgrade -y Upgrade all upgradable packages.

Screenshot-2023-10-20-120347
Upgrade all related packages

Install CURL

What we are using is Node Version Manager (NVM) Now install Node. Installing Node and npm using NVM has various benefits as it allows you to manage multiple versions of Node.js on your system together.

First you need to install curl If it is not already installed on your system. You can install curl using the command below.

sudo apt install curl -y
Screenshot-2023-10-20-122355
Installing CURL

How to install Node.js

To ensure that Node.js is successfully installed on your system, you need to follow these steps:

Install Node Version Manager (NVM)

Install Node Version Manager (NVM) using the following command:

curl -o-  | bash
Screenshot-2023-10-20-122423
Installing Node Version Manager (NVM)

When you run this particular command, curl will download the NVM installation script from that particular URL. Then bash runs the same script to install her NVM.

Activate NVM

Activate NVM using the following command:

source ~/.bashrc
Screenshot-2023-10-20-122517
Activating Node Version Manager (NVM)

Install the latest LTS version of Node

Install the latest long-term support version of Node using the following command:

nvm install --lts
Screenshot-2023-10-20-122656
Commands to install the latest LTS version of Node.js

By default, the latest version of the LTS release of Node is installed.

Create the default LTS version as NVM

Although you have installed the latest LTS version of Node, you also need to set the default version of NVM so that it is used by default whenever you need it. You can do this using the command below. Change the version to the exact LTS version you just installed on your system.

nvm alias default 18.18.2
Screenshot-2023-10-20-122842
Select the appropriate node version as the default version

If your LTS version is: 24.1.2 In that case, the command would look like this:

nvm alias default 24.1.2

Verify that node is installed

Check if the default version is the exact version you just installed using the command below.

node -v npm -v
Screenshot-2023-10-20-122937
Display the current version of installed nodes

How to set up a Node.js environment

After installing Node and NPM, you need to set up your Node environment by creating a new Node project.

Create a new directory/folder to test a simple “Hello World” type node project using the command below.

mkdir my-node-project
Screenshot-2023-10-20-123101
Creating a new directory/folder to test a simple “Hello World” program on the node

Go to. my-node-project Create a directory using the command below.

cd my-node-project
Screenshot-2023-10-20-123148
Change the directory that goes into the newly created directory/folder

Initialize a new Node project as follows:

npm init -y

This command creates a “package.json” file containing your project’s metadata and dependencies. The JSON output is as follows:

Screenshot-2023-10-20-123304-1
Initializing npm in folder

The JSON output is below.


  "name": "my-node-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": 
    "test": "echo "Error: no test specified" && exit 1"
  ,
  "keywords": [],
  "author": "",
  "license": "ISC"

Then run the setup using simple commands. For this, create a new file with the following name: app.js using Nano A text editor in the terminal.

sudo nano app.js
Screenshot-2023-10-20-123550
Open app.js file with nano

When the text editor opens, enter the following code.

console.log("Hello, Node.js from Ubuntu!");
Screenshot-2023-10-20-123710
Write simple console.log code in app.js file using nano

use Ctrl+ O Save the file.use Enter To save the file as app.js:

Screenshot-2023-10-20-123831
Save the app.js file containing the newly added lines of code.

use Ctrl + X Return to the bash terminal again.

Screenshot-2023-10-20-123907
go back to terminal

Then check the output to see if it’s working.

Use the command below.

node app.js
Screenshot-2023-10-20-124010
Running the app.js file using Node

It’s working!

You have successfully installed the latest LTS release of Node on your Ubuntu/Debian-based Linux operating system.

cheers! 🥂

conclusion

Thank you for reading this article all the way to the end.

If you like our step-by-step instructions, please let us know. Twitter/X Or LinkedIn.

If you’re interested in open source, follow me on GitHub. Be sure to check out my website too (that too!

If you want to watch programming and technology related videos, check out my YouTube channel as well.

Good luck in your programming and development journey. 😊

I can do it! Never give up! ❤️

Make money with Oziconnect referral program
Make money with Oziconnect referral program
Make money with Oziconnect referral program
Make money with Oziconnect referral program
84512

About Us

We are a leading IT agency in Lagos, Nigeria, providing IT consulting and custom software development services. We offer a wide range of IT solutions across software development, web and mobile application development, blockchain development services, digital marketing, and branding.

Contact Us

25B Lagos-Abekouta Expressway Lagos

info@ozitechgroup.com

Phone: (234) 907 155 5545

@2023 OzitechGroup – All Right Reserved.