How to install Node and NPM on Ubuntu

How to Ubuntu

Share

In this tutorial we will learn to install Node and NPM on Ubuntu.

What is Node and NPM?

Node or Node.js is an open source free server environment written in JavaScript.

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

- nodejs.org

NPM is Node Package Manager and it is used to install and manage Node packages.

Click here to install Node and NPM on macOS.

Let's install Node and NPM on our Ubuntu computer.

You can head over to nodejs.org and download the latest release of Node for your Linux computer or you can run the following commands in the terminal to install Node. I personally prefer the terminal approach.

We will be using the apt package manager to install Node and NPM.

Step #1: Update

Before we start installing Node and NPM let us go ahead and update the packages. So, open Terminal and type the following command.

$ sudo apt update

In the above command we are using sudo so, you will be prompted to enter your password.

Step #2: Install Node

Now run the following command to install Node.

$ sudo apt install nodejs

Step #3: Install NPM

Now run the following command in the terminal to install NPM the Node Package Manager.

$ sudo apt install npm

On successful installation you will be able to check the Node and NPM version by typing the following command.

Type the following command to check the Node version.

$ node -v

Type the following command to check the NPM version.

$ npm -v

At the time of writing this tutorial I was using Node v8.10.0 and NPM v6.1.0. You may have the latest version and that is totally fine.

Tips

Update NPM

To update NPM to the latest version you can use the following command.

$ sudo npm i -g npm

Remove Node

To remove Node run the following command.

$ sudo apt purge nodejs

Alright, you now have Node and NPM installed on your Ubuntu machine. Have fun developing :-)

Share