How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (2024)

Being able to install Node.js on Ubuntu or another OS is a boon for JavaScript users worldwide. If you're into JavaScript like me, installing Node.js on Ubuntu or any other operating system is a great idea. It's like having one language for all your development tasks. Before Node.js, the JavaScript folks were compelled to learn a second language that helped them perform all their backend activities, a pain in the neck. In this article, I will help you learn step-by-step how to install Node.js on Ubuntu 22.04 (Linux-based) system. Check Node.js Certification to speed up your learning curve. .

What is Node.js?

I used to think Node.js was a programming language, like many newcomers do, but it's actually not. Instead, it serves as an open-source JavaScript runtime environment, allowing the execution of JavaScript code outside the confines of a web browser. Essentially, what Node.js does is take the functionalities and features of the JavaScript language and package them into modules. It takes JavaScript, originally designed to run in a browser, and upgrades it to run in other environments. It's a versatile tool that expands the possibilities of what you can achieve with JavaScript beyond the traditional browser setting.

Because these upgrades are packaged intoNode.jsdevelopers can now use JavaScript for frontend and backend development making JavaScript a full-stack language.

In the past,Node.jswas only designed to serve real-time performance and push-back architectures. Since then,Node.jshas developed into a crucial component of server-side scripting for event-driven, non-blocking servers. Today,Node.jspowersmosttraditional websites and API services.Node.js uses an event-driven, non-blocking I/O architecture and the V8 JavaScript runtime engine as its primary power source.

Who Uses Node.js

Millions of websites all around the world use Node.js. It has millions of downloads as can be seen by its weekly npm installations.

JavaScriptfull-stackdevelopersenjoythe comfortNode.jsbrings to the technologyspace. This is becauseNode.jsenhancesthe performance of developers andfacilitatesthe development process.

Top companies that use Node.js include:

  • NASA
  • Twitter
  • Netflix
  • LinkedIn
  • PayPal
  • GitHub
  • eBay
  • Walmart
  • Spotify
  • Medium

If you research these companies,youwillnotice that they base their companies' operations onnumerous servicesor goods. However, they all share a vital characteristic whichisthat they all rely onNode.js. No matter what business you're in, employingNode.jscan solvemost ofyour development problems.

Prerequisites

Before installingthe updated node version on ubuntu, youmustensure that you’ve accumulated all the necessary knowledge. Also, make sure you’ve downloaded all required installation files and elements.

First, itwouldhelp a lot if youhada basic understanding of JavaScript and its syntax.Thisenablesyou to pick upNode.jseasily.

Secondly,youmay work on server-side coding by having a basic grasp of an object-oriented programming (OOP) language.

1. Hardware Requirements

Below are the hardware requirements for installingNode.json Ubuntu.

  • Node.js does not need a complex hardware configuration to work; most machines nowadays are compatible.
  • Node.jsinstallation requires a stable hard drive for it to work.
  • You should have the necessary prerequisites to install Node.js on Ubuntu.
  • Virtually all modem computers can runNode.Js,includingminiature computers likeBeagleBoneor Arduino YÚN.
  • The Random-Access Memory (RAM) of your system should be up to 4GB and your system storage should be at least 256GB of Hard Disk Space.

2. Software Requirements

  • Below are the software requirements for installing Node.js on Ubuntu. The web browser should be intact. Any browser such as Google Chrome, Mozilla Firefox, or Microsoft Edge can run Node.js.
  • Operating System should be accurate and free, having an Ubuntu server installed with a non-root Sudo user and firewall.

How to Install Node.js on Ubuntu [Step-by-Step]

Let me take you through the three methods below to install Node.js on your Ubuntu machine.

Method 1: Installing the Stable Version for Ubuntu

Before you can install a stable version of Node.jsfor Ubuntu,youmustupdate the terminal first.

Step 1:You can use the apt package manager to obtain the version that can run Node.js. Update the index for your regional package usage.

$ sudo apt update

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (1)

Step 2: Install Node.js from the repository in step two.

$ sudo apt install Node.js

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (2)

Step 3:Install npm ubuntu with the code below.

$ sudo apt install npm

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (3)

Step 4:Use this to check which Node.js version you installed.

$ Node.js -v && npm --version

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (4)

And there you have it for this method.If you want to upgrade your JavaScript skills, visit theFull Stack Developer courseto enhance your development skill.

Method 2: Install Node.js Using a PPA

Software repositories of various packages specifically created for Ubuntu 20.14 users are included in the PPA repository. The PPA repository for the most recent Node.jsversionisadded first.

BeforeinstallingNode.jsusing PPA, ensure that you have the curl command-line utility installed on your system.Ifcurl isn’t installed on your system paste this command on your terminal to install curl:

$ sudo apt install curl

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (5)

After installing curl add the Node.js source with the following code.

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

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (6)

If you experience an issue with the public such as“the following signatures couldn’t be verified because the public key is not available”

Now, on the console, you should see the public key; copy it, replace it in the<PUBLIC KEY>space below, and run it on the terminal.

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <PUBLIC KEY>

Now run the command below to installNode.jsnpmUbuntu 20.04 on your machine.

$ sudo apt-get install -y Node.js

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (7)

If you’ve done everything correctly, Node.js will successfully install on your Linux distribution. TochecknodeversionUbuntu,run the command shown below and the newest version is installed.

node -v && npm --version

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (8)

Method 3: Install Node.js Using NVM

The NVM (Node Version Manager) is also used to install Node.js. It has the advantage of displaying a list of all available Node.js versions, from which you can choose to either install the most recent version or a specific version. Use the instruction below to installNode.jsubuntu command line.

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

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (9)

Now install the latest Node.js on NVM using the command below.

$ nvm install node

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (10)

With the above, you will install node andnpmonUbuntu.

How toVerify the Installation

Now you’ve installedNode.js, you can verify the installation to check iftheinstallationwas successful. To confirm the installation, youmustrunthe followingLinux commands on your terminal.

To check theNode.jsversion type:

$ node -version 

And to check thenpmversion, type:

$ npm --version

TheNode.jsandnpmversion names shouldbe displayedon the terminal if they were successfully installed.

Create Demo Web Server

Step 1:Open a code editor and select a working directory.

Step 2:Create a new file calledindex.jsin the root of the working directory.

Step 3:Copy and paste the codes below inside theindex.jsfile.

const express = require('express');const app =express();[Text Wrapping Break]app.get('/', function (req, res) { res.send('Hello World!');});app.listen(3000, function () { console.log('Example app listening on port 3000!');});

Step 4:Now run the server with the code below on your terminal.

$ node index.js

The result will appear as an example app running on port 3000.

Step 5: Visithttp://127.0.0.1:3000/on the browser to see this page.

And that’s how you create a web server withNode.js.

How toUse theNode.json Ubuntu

UsingNode.json Ubuntu is simple, just as you would use it on other operating systems.

Step 1:Create a file calledindex.jsin the root of your working directory.

Step2:For this example, let’s create a simple function that adds two values together. Copy and paste the code below into yourindex.jsfile.

function add(y,z) {  returny+z;}console.log(add(81, 9))

Step3:Execute the code by running$ node index.json the terminal which would result in the output below:

// 90

How to UninstallNode.jsfrom Ubuntu?

The following instructionsremoveNode.jsfrom your Ubuntu system. 

$ sudo apt remove Node.js$sudoapt purgeNode.js-y

UninstallUsing NVM

First, check to see if it is the most recent active version.

$ nvm current

Now deactivate the version using the command below.

$ nvm deactivate

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (11)

The above command removes NVM from Ubuntu.

Advantages of Using Node.js

The correct programming platform for your tech stack is just as crucial as the amount of labor you wish to commit to it. When determining the benefits of utilizing a specific platform, a variety of criteria should be considered. The total benefit distribution may be changed by factors including the learning curve, the rate of development, the community, and scalability.

The following are the key benefits of utilizing Node.js:

  • Easy syntax
  • Easy to learn new skills
  • Quick scaling ability
  • Flexible and open source
  • Cross-platform programming
  • Full-stack single-language development
  • Instantaneous communication
  • A sizable and vibrant community

Looking to unlock the power of coding? Join ourpython programming classesand embark on a journey of endless possibilities. Discover the unique and versatile world of Python today!

Conclusion

To sum it up, learning to install Node.js on Ubuntu is a great thing for JavaScript fans like me. It means you can use one language for both frontend and backend tasks, making things simpler. Whether you go for the stable version, a PPA, or use NVM, the installation is pretty straightforward. Node.js is a big deal, used by major companies, and it makes coding more flexible and efficient. With its easy-to-understand syntax and a helpful community, Node.js is a powerful tool for building all sorts of applications. Once you have Node.js, there's a whole world of coding possibilities waiting for you!

If you want to improve your web development ability, kindly checkKnowledgeHut’sNode.js Certification.

How to Install Node.JS on Ubuntu [Step-by-Step] for Beginners (2024)
Top Articles
Complete Guide: UCLA Admission Requirements
How To Get CVV Number Without Card? [Card Verification]
Myusu Canvas
Giant Eagle Hr Conn
Noaa 7 Day Tropical Outlook
Tory Lanez Chixtape 5 Download Fakaza
Stellaris Piracy Suppression
Andrew Camarata Castle Google Maps
Jc Green Obits
Tap Into Bloomfield
247 Cincinnati
Convert Ng Dl To Pg Ml
Argus911
Drago Funeral Home & Cremation Services - Astoria - New York - Funeral Homes | Tribute Archive
TNT Tuesday Morning 09-03-2024
War Thunder M60
About Blank Games Unblocked Minecraft
Cheley Packing List
Dreammarriage.com Login
The Boogeyman Showtimes Near Century 20 Daly City And Xd
Opel Rocks-e im Test: Cooler Köder
Starrez Emerson
Weekmenu week 25 - Miljuschka
Best Car Wash Soap for 2022
Celeb Dirty Laundry General Hospital
Sam's Club Gas Price Mechanicsburg Pa
Tuscaloosa Mugshots Arrests
The Willoughbys | Rotten Tomatoes
Framingham Worcester Commuter Rail Schedule
Imvu Hov
Magicseaweed Bob Hall
Gina Wilson All Things Algebra Unit 2 Homework 8
Bookoo Garage Sales
Q Management Inc
Dr Madhuri Gudipati
Craigslist Wilmington Nc Free Stuff
Chaithanya Matrimony Login
Bison Epay
Miniature Australian Shepherd Craigslist
Msc News Atchison Ks
QUANTUM ASPEN OWNER'S MANUAL Pdf Download
2011 Jeep Liberty Serpentine Belt Diagram
Spoiler - Death Is The Only Ending For The Villain
Triad Cremation & Funeral Service Obituaries
McLaren’s Oscar Piastri putting team before self despite sensational Baku win
Bertelsmann-printing-group in Berlin auf Marktplatz-Mittelstand.de
South Bend Cars Craigslist
Lovein Funeral Obits
Jelly Mario Unblocked 76
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 5915

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.