How to install nodejs

How to install NVM in Ubuntu

What We Will Cover Here

In this tutorial, I will show you how to install NVM and then using NVM how you can install NodeJS. NVM is a node version manager. It’s a tool to install multiple versions of NodeJs into your server. Here I will show you an example that works on Amazon Linux 1 perfectly. Before you begin please check here on how to create an EC2 instance on AWS.

What is NodeJS and NVM

Node.js is an open-source, cross-platform, back-end, JavaScript runtime environment that executes JavaScript code outside a web browser. It was created on 2009 by Ryan Dahl and since then it is one the most popular JavaScript runtime environment.

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: UNIX, macOS, and windows WSL. One of the important features of NVM is that you can install multiple NodeJS versions on the same machine and switch between them with whatever version you want.

How to Install

Firstly we need to install NVM. To install NVM please run the following commands

curl -o- | bash

To verify whether you have successfully installed NVM or not, please run the following command

command -v nvm

It should output “nvm”. If not displaying “nvm” then close your session and reconnect to SSH and run the command again.

After you have installed NVM successfully, it’s now task is to install a nodejs version. There are two ways to install nodejs using NVM. To install the latest NodeJs version run the following command.

nvm install node 

This will install latest NodeJs at that particular moment.

If you want to install any specific nodeJs version then run following command

nvm install 10 # give the version number like 8 or 9 etc. 

This will install the latest version of NodeJs 10 to your server.

I have created a video as well to give a real life example. Here is the video of installing Nodejs

Spread the love