How to install Node.js and NPM on Ubuntu 18.04

In this article we are going to explain how to install Node.js on Ubuntu 18.04. This method works for local Linux machines and virtual private servers (). We’ll look at two methods and you’ll also learn how to remove the feature if you ultimately decide it’s not for you.

What is Node.js

it is one of the most popular web technologies today and is used by many developers to increase the functionality of a web application. Some of the largest companies use it; a fact that should give you an idea of ​​its potential.

In a nutshell, Node.js is a server-side execution environment that allows it to run without the client. Node.js is open source and cross-platform, which makes it ideal for different types of projects, from educational to business.

At the time of this publication, the latest stable version of Node.js is 11.10.0. However, the recommended version for most users is 10.15.1, as this is a long-term supported version.

There are several ways to install Node.js, here we show you the two simplest and most efficient.

ImportantNote: Before you begin, you must have access to your server and be able to run commands using sudo. Check out the tutorial for . Also, keep in mind that you shouldn’t apply both methods; just choose the one that best suits your needs.

Install Node.js and NPM from the official Ubuntu repository

The easiest and fastest way to install Node.js on a server running Ubuntu 18.04 is through the official repository.

First, connect to the server using ssh.

See also  Best Booking Plugin for WordPress: 10 Free and Paid Alternatives

ssh username@server_ip_address

If you’re running a system with , simply open a terminal emulator from the main menu.

When you are connected, refresh the APT cache. To do this, run the following command:

sudo apt update

With this we make sure that the repositories are synchronized and the system can safely download what is stored in them.

Next, you can install Node.js by running the following command.

sudo apt install nodejs

After entering your password, the installation process will begin.

You can also install NPM, which is the package manager for node.js.

sudo apt install npm

Lastly, check the installed version. To do so, run the following command:

nodejs -v

This is the easiest way to install Node.js on a Linux machine or Linux based VPS.

To remove Node.js, run this command:

sudo apt remove nodejs

Install a specific version of Node.js using NVM

There is another way to install Node.js on a server running Ubuntu 18.04. Using an NVM (Node Version Manager), we can choose a specific version to install. This is great if you want to use an LTS version or just the latest version available.

First, download NVM using wget. If you’re not sure if you have , run this command.

sudo apt install wget

Now run this command:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

The next step is to allow NVM to be used from your user’s bash profile by running this command:

source ~/.profile

Now you can use NVM to list all versions of Node.js available to install.

nvm ls-remote

Freely choose the one you want. For more stability and support we recommend version 10.15.1. To do so, run this command:

See also  Top 15 Alternatives to WordPress in 2022

nvm install 10.15.1

You can check if the installation was successful by checking the Node.js version. To do this, run:

node -v

As you can see, everything went well. Node.js is successfully installed and ready to use.

If you want to uninstall Node.js and you had installed it using this method, disable it first.

deactivate nvm

You can then proceed to uninstall Node.js.

nvm uninstall v10.15.1

conclusion

Node.js is a very useful technology for developing web applications. Installing it on a server running Ubuntu 18.04 is easy and we have shown you two ways to do it.

Gustavo is passionate about creating websites. He focuses on the application of SEO strategies at for Spain and Latin America, as well as the creation of high-level content. When he is not applying new WordPress tricks you can find him playing the guitar, traveling or taking an online course.

Loading Facebook Comments ...
Loading Disqus Comments ...