Blog Post
How to Install Node.js on Ubuntu

How to Install Node.js on Ubuntu

Node.js is a brilliant runtime environment that serves thousands of developers to design server-side web apps. The technology has been incredibly popular during the last several years, and this quick tutorial will show you how to install Node.js on Ubuntu. The process is simple and should work on any of the LTS releases of any distro.

What You Need to Install Node.js on Ubuntu

There are two things you should secure to perform a Node.js installation on an Ubuntu OS successfully:

  • Updated operating system – the best way to keep your data safe is to update Ubuntu regularly.
  • Root user – alternatively, you can also use another user that has superuser, in that case, all the commands should have the “sudo” prefix.

METHOD 1: Use the Official Repository

If you want to keep things simple, use the command line to type the following:

apt install nodejs

Do not forget that you should also install the Node.js package manager. Do that by typing this line:

apt install npm

The system will install both in a matter of seconds, and you will be good to go. The next thing you will need is a reliable Linux code editor or IDE.

When the time comes you do not want to use Node.js anymore, you can delete it by typing the following:

apt remove npm nodejs

Linux will now uninstall both the package manager and the Node.js.

METHOD 2: Use NodeSource Repository

We won’t ask why you do not want to use the official Ubuntu’s repository, but the alternative you can consider is using NodeSource directly.

Here is how the command should look:

curl -sL | sudo -E bash -

Instead of “10,” you can choose any other version of the runtime environment to install.

The system should download and run the script to add the NodeSource depository to the directory that lists sources.

Now, use the standard installation command to set up both Node.js and npm at once.

apt install nodejs

To make sure everything went according to the plan, check the version you installed:

node --version

Linux will now display the version installed on your system. You can do the same for “npm” if you type if instead of “node” in the line above.

verify nodejs version

Wrap Up

The beauty of Linux lies in its simplicity, and the variety of operating systems for different types of users. If you are truly passionate about Node.js, consider installing NodeOS, which is a Linux distro specifically designed for the users of this runtime environment.

Related posts

Leave a Reply

Required fields are marked *

Copyright © 2022 All rights reserved.