Easy node installation on ubuntu

Easy Node Installation on Ubuntu

The globe’s biggest software registry is npm which is the standard package management for Node.js. Programming, on the server side, may be done with the JavaScript runtime Node.js. With JavaScript—a technology that many have become acquainted with via browser-based web development—developers may use it to construct a scalable core functionality. Typically, networking and server-side programs are built considering it, making it fast and robust. We’ll go over a few easy ways to install Node on an Ubuntu system. Select the installation technique that works best for the environment that you are in.

Update the Ubuntu Repositories

Let’s begin with the launch of the Command Terminal on the Ubuntu system. Before moving towards the different methods to install Node on the Ubuntu system, we need to update the repositories of our Ubuntu system using the “apt” package in the “update” instruction.

Sponsored
$ sudo apt update

Easy node installation on ubuntu 1

Check the Node Version

Before installing Node on the Ubuntu system, you should be sure that it’s not already installed at your end. For this, the use of “version” instruction is more than enough. Use the “node” keyword followed by the “-v” option to check the version of the Node. The output displays that it’s not found in the system and you need to install it.

$ node -v

Easy node installation on ubuntu 2

Install Node Using the Apt Default Repository

The first and easiest way to install any program in an Ubuntu system is to use the “Apt” default package in the command shell. The “install” instruction should be executed by the use of the default “Apt” package and the “nodejs” keyword at the end. Make sure to run this query with “sudo” rights to avoid any privilege issues while working. Right after the execution of this query, the installation processing starts.

See also  UX Deep Dive: Classify interactions for a more intuitive user interface
$ sudo apt install nodejs

Easy node installation on ubuntu 3

While the process of execution of the previous instruction has taken place, it requires the availability of a 30.7MB disk on your Ubuntu machine. Make sure to have that and affirm yes by tapping on the “y” key as depicted in the following:

Easy node installation on ubuntu 4

To confirm the installation and the installed version of Node on the Ubuntu system, run the “version” instruction by utilizing the “-V” option as shown in the following. The installed version is displayed on the terminal screen as follows:

Easy node installation on ubuntu 5

Configure Node.js if the bundle in the repositories that meets your requirements just takes a few minutes. Most of the time, installing npm—the Node.js package manager—is also something that you should do. To accomplish this, use “apt” to set up the npm package in your Ubuntu system as follows:

$ sudo apt install npm

Easy node installation on ubuntu 6

Affirm installing the npm package manager by pressing “y” upon prompt.

Easy node installation on ubuntu 7

Wait until the node package manager “npm” gets installed as depicted in the following image:

Easy node installation on ubuntu 8

After certain processing, the node package manager will be successfully installed.

Easy node installation on ubuntu 9

Install Node Using the Node Source PPA

Users can employ a PPA (personal package archive) that is kept up-to-date by NodeSource to set up an alternative release of Node.js. Compared to the standard Ubuntu repository, these PPAs offer more Node.js releases. First, we must ensure that the system is not affected by the previous installation. So, we update the “apt” packages and repositories via the “update” instruction.

$ sudo apt-get update

Easy node installation on ubuntu 10

After the update, make sure to update the system repositories and packages so that the system can get the effects of the new installations to be made. Therefore, the shell utilizes the “upgrade” instruction via the “apt-get” package.

Sponsored
$ sudo apt-get upgrade

Easy node installation on ubuntu 11

Make sure to affirm that you want to continue this upgrade and wait for a while.

Easy node installation on ubuntu 12

After a successful update and upgrade, you need to use the “cd” instruction to move within the home directory of your Ubuntu machine. After this, we move towards using an instruction to get the Node.js from its source. So, the “curl” utility is utilized in the instruction with the “-sL” option to get the setup of the Node.js version 16 from the source site and make its object file in the “tmp” folder using the “-o” option. This is going to be the downloaded Node script that we can go through.

$ cd ~

$ cd -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh

Easy node installation on ubuntu 13

Now, the built-in “GNU Nano” editor is utilized in the command shell to open the newly created “nodesource_setup.sh” script file in the “tmp” folder to review it.

$ nano /tmp/nodesource_setup.sh

The setup node source Bash file will be opened in the nano editor. You can edit it if you want to and save it untouched if you are satisfied with the contents of this file.

Easy node installation on ubuntu 14

The script of the file is displayed as follows:

Easy node installation on ubuntu 15

It’s time to run the Bash “script” file that we reviewed. Make sure to only run it when you are totally satisfied with its script. The “bash” instruction executes the file using the file path and the sudo rights. The execution may display a warning that the running script might be deprecated, and you should installs another node version via the node source. Follow the instructions after that.

$ sudo bash /tmp/nodesource_setup.sh

Easy node installation on ubuntu 16

After the successful execution of the Bash script, the ppa of the Node will be added to your system configuration successfully. Now, it’s time to install the loaded Node version on our system using the same “install” command with the “apt-get” package. The latest version of Node will be installed successfully at our end.

$ sudo apt install nodejs

Easy node installation on ubuntu 17

Uninstall Node

If you don’t need the feel to use the Node in your Ubuntu Linux environment, you can remove it via the “apt” package followed by the “remove” keyword and the “nodejs” package name.

$ sudo apt remove nodejs

Easy node installation on ubuntu 18

To automatically remove its documentation folders and cached data, make sure to use the “purge” instruction as well.

$ sudo apt purge nodejs

Easy node installation on ubuntu 19

Conclusion

This guide contains all the instructions that you need to install the latest Node version on the Ubuntu system. Within this guide, we discussed two different ways to simply install the Node like using the default “apt” repository and the node source ppa. In the end, we also discussed how to completely remove it from the system.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply