How to Deploy a Node Js application on AWS with Filezilla

Description of the image

Are you looking for the deployment of your Node Js App? Then you are in the correct place, in this article, we will explain how you can learn How to Deploy a Node.js application on AWS with Filezilla and how to access it on your browser, here will configure nvm, node js, and security group on the ec2 instance.

Getting Started With Node Js

In this first step, we will create a node js project which will run on port 3000. In which there will be 2-3 simple routes and it will return JSON.

Create an App

To create an app run the following commands

npm init 
npm install express nodemon 
create a file named server.js 
paste the following code  

const express = require('express'); 
const app = express();
const APP_PORT = process.env.PORT || 3000; 
app.get('/',function(req,res){ res.json({ status:200, message:'Welcome' }) });
app.listen(APP_PORT, () => { console.log(`Server Started At PORT ${APP_PORT}`); });

how to deploy a node js application on aws

Setup the Instance

Connect the ec2 instance VIA terminal and install the node js and npm by NVM.

Installing NVM

Execute the following commands for NVM installation 

curl -o- | bash . ~/.nvm/ nvm install node nvm install 14.15 nvm use 14.15  

Setup FileZilla

You can simply move the file(node js) through Filezilla to the server.
for this procedure, you need the PEM file which you can get while configuring the EC2 instance.

Running the App

Now go back to the terminal and navigate to the folder and run the start command but before starting the app execute the npm install this will install all necessary packages then 
npm start and open your ec2 instance and copy the public IP and try to access the app from the browser.

Setup Security Group

When you access the app from the browser then it will not work because you haven't the setup the security group for the EC2,
Go and select ec2 instance scroll down click on Security and open the security group.

Here we will have to create a security group for 3000 ports. To create click on Edit inbound rules click on Add rules and follow the screenshot.

Now click on save rules. Now at some times, you can access the app from the browser by IP

Conclusion - How to Deploy a Node Js application on AWS with Filezilla

In the above article, we learned how we can deploy our node js app on AWS. we explored security groups, Filezilla, and nvm installation.
By Filezilla, you can simply drag and drop the files and folder from local to server as we have done in the above process..

Table of Contents

    Leave a reply

    Subscribe to Us

    Always Get Notified