Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » How to install Node.js on Ubuntu
  • sync
    AD Connect Sync Service Not Running: Start ADSync to Continue AWS/Azure/OpenShift
  • How to use Netstat.exe to confirm which Program uses or blocks a port
    How to use Netstat.exe to confirm which Program uses or blocks a port Linux
  • Windows 10 1903 update 1
    view or change programs that run on startup on Windows Windows
  • Driver Automation Tool
    Windows Driver Management: Upgrade Driver Automation Tool Windows
  • image 19
    Download your MySQL database from Azure to a local PC with MySQL Workbench AWS/Azure/OpenShift
  • DELL Data Protection
    How does DELL Free Fall Data Protection work? Windows
  • google sdk feature
    How To Install Google Cloud SDK on a Linux System Linux
  • ddf 2
    Add boot and install images to WDS and configure Multicast transmission via the GUI and WDSUTIL Windows Server

How to install Node.js on Ubuntu

Posted on 23/03/202204/07/2023 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on How to install Node.js on Ubuntu
feature-image-nodejs

Node.js is a server-side programming runtime based on JavaScript. It enables developers to design scalable backend functionality using JavaScript. JavaScript is a language that many people are already familiar with through web development in the browser. Node takes JavaScript out of the browser. As a result, developers can utilize JavaScript to perform anything that other popular server-side languages like Ruby, PHP, C#, and Python can do. So, at its most basic level, NodeJS allows you to run JavaScript code on a machine other than a web browser, such as your local computer or a server. Do you want to learn how to install Node.js on Ubuntu? Read on to gain more insights about Node.js and the installation process.

NodeJS provides certain extra features that browser-based JavaScript doesn’t have, such as the ability to read and write local files, create HTTP connections, and listen for network requests. This tutorial will guide you on how to install Node.js on any Ubuntu server. While the commands will work on most servers but for the purpose of the demos, we used version 20. Explore other guides here: Squid Proxy: How to setup and configure a Proxy Server/, How to install MariaDB on Ubuntu/, How to Install Terraform on Linux/, How to install Apache Tomcat on Ubuntu

Event-driven

Because of its single-threaded nature, Node.js is suitable for non-blocking, event-driven servers. It was created with real-time, push-based architectures in mind and is utilized for standard websites and back-end API applications. If we look through the official website of NodeJS nodejs.org for a proper definition, we will see that NodeJS is a JavaScript runtime. The runtime is also event-driven and asynchronous at the same time. In this case, asynchronous means that you don’t try to forecast the exact order which each line will execute when you write your code. Instead, you write your code as a series of smaller functions that are invoked when certain events occur, like a network request (event-driven).

Consider the following scenario: you’re writing a program that must read text from a file, print that text to the console, query a database for a list of users, and filter those users based on their age.

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
}).listen(8080);

Essentially, this code creates a server and instructs it to “perform this callback function whenever we receive a network request.” The text ‘Hello World’ is returned by this function. That text would appear on your screen if you opened a browser and navigated to the correct location and port.

Importance of Installing Node.js on Ubuntu

  1. Calling other services using Node.js is simple. The majority of apps require seamless communication with the database and platform API.
  2. Node.js increases efficiency and can manage a large number of queries. It’s incredibly handy, practical, and speedy on the client side because it requires consumers to make fewer clicks and have everything loaded directly.
  3. Node.js allows developers to use JavaScript on both the server and the browser.
  4. With its lightweight and diverse tools, Node.js allows developers to speed up the development of online apps.
  5. Back-end frameworks run on Nodejs, which is an environment. Express.js is one of such frameworks (or just Express) is a popular HTTP server , while Socket.IO is a popular WebSocket server that also runs on NodeJS.
  6.  As a stand-alone platform, Node.js provides numerous advantages to the tech stack; for example, it includes the JSON module library. Node.js has become a major participant in several IT ecosystems, with over 368,985,988 downloads, or an average of 1,010,921 every day.

Prerequisites for Installing Node.js on Ubuntu

You should have a non-root user account with sudo rights set up on your system before you begin.

 Possibility No. 1: Installing with Apt from the Default Repositories

In Ubuntu 20.04’s default repositories, there is a version of Node.js that can be used to give a consistent experience across various platforms. The version in the repositories at the time of writing is 10.19. This will not be the most recent version, but it should be dependable.

The apt package manager can be used to obtain this version. To begin, refresh your local package index by typing:

$ sudo apt update 

Install NodeJS:

sudo apt install nodejs
how to install Node.js on Ubuntu

to check the version installed

node -v
how to install Node.js on Ubuntu-node-v

You should also install the Node.js package manager, npm. You can do this by using apt to install the npm package:

sudo apt install npm
npm-v

Using apt and the default Ubuntu software repositories, we were able to successfully install Node.js and npm.

 Possibility No. 2: Installing Node.js Using the Node Version Manager

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh
FIRST
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
how to install Node.js on Ubuntu-DOWNLOAD

The nvm script will now be installed in your user account. You must first source your.bashrc file in order to utilize it:

source ~/.bashrc

source the ~/.bash profile file with the command:

source ~/.bash profile

We can now ask NVM which Node versions are available:

nvm list-remote
how to install Node.js on Ubuntu-versions

It’s a lengthy list! By typing any of the release versions you see, you can install a version of Node. For example, to obtain version 14.10.0, type:

nvm install v14.10.0
how to install Node.js on Ubuntu-npms

you can see the various versions you have installed with the command below:

nvm list
how to install Node.js on Ubuntu-npmlist

On the first line, the display shows the currently active version (-> v14.10.0), followed by various named aliases and the versions to which those aliases point.

Summary

Node.js is outstanding and efficient at managing several requests at once. It takes others longer and costs less than other IT giants to handle your app’s traffic. We have installed Node.js on Ubuntu using two different methods, first, from the Default Repositories and lastly using the Node Version Manager.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:Ubuntu

Post navigation

Previous Post: How to apply Windows Updates with PowerShell
Next Post: How to install and configure Tripwire on Ubuntu

Related Posts

  • Locate Find and Grep Required 1
    Locate, Find and Grep: Search for files and patterns in Linux or Unix-like OS Linux
  • feature image sublime text 4
    How to install Sublime Text 4 on Ubuntu Linux
  • feature image mongo
    How to Install MongoDB on a Linux System Linux
  • LAMP
    How to setup and configure a Lamp stack on CentOS Linux
  • 517443 637286201540125528 16x9 1
    User account and process management in Linux Linux
  • screenshot 2020 05 05 at 22.42.35
    How to run Windows applications on Linux via WineHQ Linux

More Related Articles

Locate Find and Grep Required 1 Locate, Find and Grep: Search for files and patterns in Linux or Unix-like OS Linux
feature image sublime text 4 How to install Sublime Text 4 on Ubuntu Linux
feature image mongo How to Install MongoDB on a Linux System Linux
LAMP How to setup and configure a Lamp stack on CentOS Linux
517443 637286201540125528 16x9 1 User account and process management in Linux Linux
screenshot 2020 05 05 at 22.42.35 How to run Windows applications on Linux via WineHQ Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • sync
    AD Connect Sync Service Not Running: Start ADSync to Continue AWS/Azure/OpenShift
  • How to use Netstat.exe to confirm which Program uses or blocks a port
    How to use Netstat.exe to confirm which Program uses or blocks a port Linux
  • Windows 10 1903 update 1
    view or change programs that run on startup on Windows Windows
  • Driver Automation Tool
    Windows Driver Management: Upgrade Driver Automation Tool Windows
  • image 19
    Download your MySQL database from Azure to a local PC with MySQL Workbench AWS/Azure/OpenShift
  • DELL Data Protection
    How does DELL Free Fall Data Protection work? Windows
  • google sdk feature
    How To Install Google Cloud SDK on a Linux System Linux
  • ddf 2
    Add boot and install images to WDS and configure Multicast transmission via the GUI and WDSUTIL Windows Server

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.