[2 Simple Ways] Install Node.js on Ubuntu 16.04 – Beginner Tutorial

[2 Simple Ways] Install Node.js on Ubuntu 16.04 – Beginner Tutorial

Node.js is a open source environment which is free and very useful in developing network applications.

If you are building application which runs on distributed system and requires sensitive data handling, then you should using node.js for that. Node.js is light weight and uses java.

Today, in this article you are going to see How to install Node.js on Ubuntu. Just follow the below steps to proceed further.

Requirements:

  • You should have configured your Ubuntu 16.04 as mentioned in this server setup guide.

Install NodeJS on Ubuntu

Ubuntu has a lot of software on it’s repositories. It makes our job much easier to install Node.js on Ubuntu server. All you need is just execute the two commands.

Also, the main thing is Ubuntu does not always contains the latest version of applications and software.

But:

Most of the software in repositories are stable one.

Here, let us install existing version in Ubuntu repository.

First, update the apt package manager.

Now, let us install node js using the below command.

When you install Node Js, you should also install NPM along with it.

What is NPM?

NPM is node.js package manager. It will contain all the necessary file for your project module.

To install NPM, use the below command.

The NPM will help you to install all the necessary packages and modules in the server.

To check the version of Node.js, use the below command.

We cannot exactly tell whether this version of Node js suitable for all your requirements for developing applications.

Installing Nodejs Version 8 on Ubuntu

The another way of installing latest version of Node.js is downloading and installing it from official site. We can get the latest version from adding the PPA to Ubuntu repository.

It will have more updated version of Node.js. Now, the current version of Node js is 10.x.

Also, Node js v 8.x is still in use widely and supported upto next year december.

In this tutorial, i am going to install Node.js version 8.

Now, go to the home folder

Then, use the below command to pull the node js setup file from the web.

If you want to see the files inside, use the nano editor for it.

If you want to run the script, use bash with sudo.

Now, the PPA will be added to the repository and you can install node.js as same as previous methods.

Now, you can check the node js version as mentioned above.

Unlike the previous methods, this second method of installation will automatically install the Node Package Manager.

A configuration file will be created during the installation of Node.js which will be used by NPM to keep track of updates.

To check the npm version use the below command.

It will display your current version of NPM.

There is one more command remaining to run. Some node packages only run if you install build-essential package.

The above are the two easy methods to install Node.js

Uninstalling Node.js from Ubuntu

If you would like to uninstall Node.js from Ubuntu, then follow this command.

If you installed Node.js from the ubuntu repositories, then you have to use the apt-get utility.

This command simply remove the Node.js package files but does not remove the configuration file. This command is useful if you want to install Node Js later on.

If not and you want to completely remove the Node.js, then use the below command.

Now, all the configuration files will be removed. The last command to execute is autoremove.

This command will remove the rest of the unused package installed during the other package installation.

If you want to remove a version of Node.js, first you have to find whether that version is current and in use.

If not, just use the below command to uninstall node.js.

Here, in the above command, you have to mention the node version to remove.

if that is current version of node, first deactivate it using below command.

This command will not remove the cached files but later it will be useful if you want to install Node.js later.

Conclusion

Node.js has been widely used. If you are facing any error or issues, then just let me know that in comment section.

Also, subscribe for our tutorial news letter to get notified for the next tutorial.

 

Leave a Reply

Your email address will not be published. Required fields are marked *