DEV Community


Posted on • Updated on • Originally published at


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,

click on the launch instance button and it will ask you to select the virtual instance operating system and 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.

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

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

curl -o- | bash

it will install the nvm in our ec2 instance.

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

. ~/.nvm/

Now, use nvm to install the nodejs on ec2 instance

nvm install node

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


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.

Refer Official Documentation of AWS to learn more about installation on different VM's :

Top comments (2)

crimsonmed profile image
Médéric Burlet

This somewhat looks very similar from the official Amazon documentation:

ganeshmani profile image

The way we do the installation will be similar to official documentation most of the time..i wanted to write an article to cover both aws ec2 setup and nodejs installation in a practical way rather than showing just some commands. that's why i wrote this article to refer in future.

Super Useful CSS Resources

A collection of 70 hand-picked, web-based tools which are actually useful.
Each will generate pure CSS without the need for JS or any external libraries.