Categories: UbuntuUbuntu Feed

How to Install Latest Node.js on Ubuntu

If you’ve been exploring the world of front-end and JavaScript, you might have come across Node.js. It is a server-side framework that uses Google’s V8 engine to execute JavaScript code. Developers can use Node.js as it provides them with an easy way to build fast and scalable network applications, using single-threaded asynchronous events.

In this article, we will see how to install Node.js on Ubuntu and its derivatives via a new official PPA repository. If you are new to Ubuntu or any other Linux operating system, then be sure to check out our beginner’s guide first.

You can also use the popular Node Version Manager (NVM)

Sponsored
for installing specific Node.js version on your system.

Step 1 – Configuring Node.Js PPA

Node.js releases are available in two types, one is the LTS release, and the other is the current release. Choose any one version of your choice or as per the project requirements. Let’s add the PPA to your system to install Nodejs on Ubuntu.

  • Use Current Release –
  • During the last update of this tutorial, Node.js 18 is the current Node.js version available.
sudo apt-get install curl 
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - 

  • Use LTS Release – Instead of current release, its good idea to use stable version. During the last update of this tutorial, Node.js 16 is the latest LTS release available.
    sudo apt-get install curl 
    curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - 
    
  • For this tutorial, I am using the latest current release and added their PPA to my system.

    Step 2 – Install Node.js on Ubuntu

    You have successfully configured Node.js PPA in your Ubuntu system. Now execute the below command to install Node on and Ubuntu using apt-get. This will also install NPM with node.js. This command also installs many other dependent packages on your system.

    sudo apt install nodejs 
    

    That’s it. This will install Node.js on your Ubuntu system.

    Step 3 – Check Node.js and NPM Version

    After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

    Sponsored
    node -v  
    
    v16.15.1
    

    Also, check the npm version

    npm -v  
    
    7.13.0
    

    Step 4 – Create Demo Web Server (Optional)

    This is an optional step. Suppose you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file server.js

    sudo nano server.js 
    

    and add the following content

    server.js
    var http = require('http');
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello Worldn');
    }).listen(3000, "127.0.0.1");
    console.log('Server running at http://127.0.0.1:3000/');
    

    Save the file and close. Then start the Node application using the following command.

    node server.js 
    
    debugger listening on port 5858
    Server running at http://127.0.0.1:3000/
    

    You can also start the application with debugging enabled with the following commands.

    node --inspect server.js 
    
    Debugger listening on ws://127.0.0.1:9229/938cf97a-a9e6-4672-922d-a22479ce4e29
    For help, see: https://nodejs.org/en/docs/inspector
    Server running at http://127.0.0.1:3000/
    

    The web server has been started on port 3000. Now access http://127.0.0.1:3000/ URL in browser. Now you will need to configure a front-end server for your app.

    Conclusion

    In conclusion, we have seen how to install Node.js on Ubuntu and its derivatives via a new official PPA repository. This makes it easy for us to get started with Node.js development on our Linux systems. We can also use this repository to keep our installations up-to-date with the latest stable versions of Node.js. Be sure to check out other tutorials on our website for more tips and tricks about using Node.js!

    The post How to Install Latest Node.js on Ubuntu appeared first on TecAdmin.

    Ubuntu Server Admin

    Recent Posts

    Canonical Releases Ubuntu 25.04 Plucky Puffin

    The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

    2 days ago

    Ubuntu 25.04 (Plucky Puffin) Released

    Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

    3 days ago

    Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

    Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

    3 days ago

    Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

    Focal Fossa will reach the End of Standard Support in May 2025, also known as…

    4 days ago

    Ubuntu MATE 25.04 Release Notes

    Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

    4 days ago

    Ubuntu Weekly Newsletter Issue 887

    Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

    5 days ago