How to Install Nodejs in AWS EC2 in a proper way

In this article, we will see how to install nodejs in AWS EC2 instance in a proper way. How to Install Nodejs in AWS EC2 in a proper way.

Recent Articles

Building Real time API using graphql subscriptions

Introduction to AWS SNS using Nodejs

Building Modern Nodejs Application using Nestjs and TypeScript

Before proceeding further, i assume that you have basic understanding of what is AWS EC2 and some of AWS concepts. read this article to know more about AWS EC2

If you are already familiar with AWS EC2, you can skip the below part and go to the installing nodejs part of this article.

AWS EC2 Setup

Create an account in AWS and go to EC2 in the aws Dashboard. In the AWS EC2 dashboard, you can see a launch instance button,

dashboard

click on the launch instance button and it will ask you to select the virtual instance operating system and storage.

storage

Select any free tier instance (operating system) that you want, and continue the process.

After that, it will ask you to select the type of instance that you want for your server.

instace type

Once you click the launch, you need to review all the configuration that you have selected and generate the key value pair,

key gen

if you already have aws key, you can use the existing key for this server also, Or else you can create a new one.

Remember, this key should be shared with anyone else under any circumstance. also, make sure you do not lose the key. that's very important.

After completing the process, you're ec2 instance will be ready.

Now, it is time to install the nodejs in the aws ec2.

Installing Nodejs in AWS EC2

Mainly, we will be using nvm to install and manage nodejs. important feature of nvm is we can upgrade and downgrade nodejs easily using nvm.

Let's install nvm in AWS EC2 using the command

1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

it will install the nvm in our ec2 instance.

install nvm

After that,you need to activate the nvm to use it. activate the nvm using the command,

1. ~/.nvm/nvm.sh

avtivate nvm

Now, use nvm to install the nodejs on ec2 instance

1nvm install node

install node

Node is installed successfully on the instance. you can test the nodejs byb checking the version of nodejs and npm.

verify install

Summary

To sum up, it installs the nodejs on AWS ec2 instance. important thing to note here is, you can upgrade the nodejs version easily using nvm.

To Read More

I Accidentally wiped the entire dat...

One of the tragic accident in my job turned out to be good learning for me in re...

List of Docker Container Commands y...

This article covers list of commands that you should know to manage docker conta...

Everything you need to know about d...

Docker volume is a persistent data storage mechanism to store the data in docker...