How to Install Nodejs in AWS EC2 in a proper way
Tags: aws, node, webdev, showdev
Published: 2019-12-20 18:54:10

---
title: How to Install Nodejs in AWS EC2 in a proper way
published: true
description: How to Install Nodejs in AWS EC2 in a proper way
tags: aws,node,webdev,showdev
canonical_url: https://cloudnweb.dev/2019/12/how-to-install-nodejs-in-aws-ec2-in-a-proper-way/
---

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Recent Articles</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://cloudnweb.dev/2019/12/building-real-time-api-using-graphql-subscriptions/">Building Real time API using graphql subscriptions</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://cloudnweb.dev/2019/12/introduction-to-aws-sns-using-nodejs/">Introduction to AWS SNS using Nodejs</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="https://cloudnweb.dev/2019/12/building-modern-nodejs-application-using-nestjs-and-typescript/">Building Modern Nodejs Application using Nestjs and TypeScript</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Before proceeding further, i assume that you have basic understanding of what is AWS EC2 and some of <a href="https://click.linksynergy.com/deeplink?id=YIJ5oggSvpI&amp;mid=39197&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Faws-certified-developer-associate-dva-c01%2F">AWS concepts</a>. read this article to know more about <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html">AWS EC2</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you are already familiar with <a href="https://click.linksynergy.com/deeplink?id=YIJ5oggSvpI&amp;mid=39197&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Faws-certified-developer-associate-dva-c01%2F">AWS EC2</a>, you can skip the below part and  go to the installing nodejs part of this article.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>AWS EC2 Setup</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Create an account in AWS and go to EC2 in the aws Dashboard. In the AWS EC2 dashboard, you can see a<strong> launch instance</strong> button,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1912,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/dashboard-1024x545.png" alt="" class="wp-image-1912"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>click on the launch instance button and it will ask you to select the virtual instance operating system and storage.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1913,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/storage-1024x429.png" alt="" class="wp-image-1913"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Select any free tier instance (operating system) that you want, and continue the process. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After that, it will ask you to select the type of instance that you want for your server.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1914,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/instace_type-1024x463.png" alt="" class="wp-image-1914"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once you click the launch, you need to review all the configuration that you have selected and generate the key value pair,</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1915,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/key_gen.png" alt="" class="wp-image-1915"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>if you already have aws key, you can use the existing key for this server also, Or else you can create a new one.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After completing the process, you're ec2 instance will be ready.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Now, it is time to install the nodejs in the aws ec2.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Installing Nodejs in AWS EC2</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Mainly, we will be using <a href="https://github.com/nvm-sh/nvm">nvm </a>to install and manage nodejs. important feature of nvm is we can upgrade and downgrade nodejs easily using nvm.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Let's install nvm in AWS EC2 using the command</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>it will install the nvm in our ec2 instance.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1918,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/install_nvm-1024x232.png" alt="" class="wp-image-1918"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>After that,you need to activate the nvm to use it. activate the nvm using the command,</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>. ~/.nvm/nvm.sh</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":1919,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/avtivate_nvm.png" alt="" class="wp-image-1919"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now, use nvm to install the <a href="https://click.linksynergy.com/link?id=YIJ5oggSvpI&amp;offerid=507388.922484&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-nodejs-developer-course-2%2F">nodejs </a>on ec2 instance</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>nvm install node</code></pre>
<!-- /wp:code -->

<!-- wp:image {"id":1920,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/install_node.png" alt="" class="wp-image-1920"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><a href="https://click.linksynergy.com/link?id=YIJ5oggSvpI&amp;offerid=507388.922484&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-nodejs-developer-course-2%2F">Node </a>is installed successfully on the instance. you can test the nodejs byb checking the version of nodejs and npm.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":1922,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cloudnweb.dev/wp-content/uploads/2019/12/verify_install.png" alt="" class="wp-image-1922"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3>Summary</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
Refer Official Documentation of AWS to learn more about installation on different VM's : https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
<!-- /wp:paragraph -->