close

Node.Js is an open source and cross-platform Server Side JavaScript run time developed to executes JavaScript code outside of a browser. So with Node.js you can run your Javascript on your machine as a standalone application. Thanks to Node.js now you can do much more with JavaScript than just making websites interactive in short now using Javascript you can do stuff what other scripting language like python can do outside the browser. With the Node.js framework, you opt to install the NPM (node package manager) from which you are able to use thousands of Node.js modules from its library to your application. Moreover, NPM makes it easy for JavaScript developers to share the code they have created to solve particular problems and for other developers to reuse that code in their own applications. So in this article, I will guide you on how to install Node.js® and NPM on Ubuntu 18.04.

Method 1: Install Node.js from the Ubuntu repository

Ubuntu 18.04 contains a version of Node.js in its default repositories that can be used to provide a stable experience.  It will not be latest but it should be stable.

To get this version, you can use the apt package manager. Update your local package with command given below:

 $  sudo apt update

Now Install Node.js from the repositories using command given below:

 $  sudo apt install nodejs

Above command will start installing nodejs and its dependencies so you have to wait until every thing done it might take few seconds. Once it is done you can verify nodejs installation by checking Nodejs and node package manager’s version using command given below

 $  node -v
 $  npm -v

Above command will show installed versions of nodejs and npm.

check nodejs and npm version

Method 2: Install Node.js Latest Version

To get a more recent version of Node.js you can add the PPA (personal package archive) as this will have more up-to-date versions of Node.js than official Ubuntu repositories.

We will need curl to add node.js ppa in our system. In addition we will also need to install python-software-properties package if its is not installed already.

 $ sudo apt-get install curl
 $ sudo apt-get install python-software-properties

Now Adding NodeJs PPA :

 $  curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

After adding the node.js ppa we just need to give the node.js install command to install node.js. Npm will be installed automatically with node.js.

 $ sudo apt-get install nodejs

Once completed, I will run the command below to check that I’ve installed the correct version

 $  node -v  //output: v11.5.0
 $  npm -v   //output: 6.4.1

Removing Node.js

You can uninstall Node.js using apt command given below:

 $  sudo apt remove nodejs

This command will remove the package and retain the configuration files. These may be of use to you if you intend to install the package again at a later point.

In the end you can see that there are a quite a few ways to get up and running with Node.js on your Ubuntu 18.04 server. Your need will dictate which of the above methods is best for your situation.

Tags : Install Node.JS on UbuntuNodeJSUbuntuUbuntu 18.04 LTS

About Author

EDITORIAL STAFF

EDITORIAL STAFF

Read latest technology news, reviews, how-to guides and other tips & tricks covering Windows, Linux, Mac & Android operating systems prepared by our team.