Install node js amazon linux6/21/2023 In this specific case, it just runs node index.js, though in reality, it could be much more than that. Once the package.json file is created, open it up and add the following line to the beginning of the scripts section: "start": "node index.js",īy doing this, instead of running node index.js, we'll be using npm start, which will run everything in our script. This will generate our package.json file, which is essentially a configuration file for our app. Let's stick with the NPM defaults for now - this article will assume you left the entry point as index.js. This will create a new folder, move into that folder, and then initialize a new Node application. To do this, we'll open up a terminal and run: $ mkdir node-ec2 $ cd node-ec2 $ npm init Let's make a really simple Node application that responds to a request. This article will assume basic familiarity with Docker, and won't be going into any depth on it - however, if you'd like to do a deeper dive then check out Deploying a Node.js App to a DigitalOcean Droplet with Docker. This means no more of that 'but it works on my machine!' Dockerĭocker allows us to bundle up our applications into small, easily deployable units that can be run anywhere where Docker is installed. As EC2 is an AWS service, we'll need to set up an AWS account.ĪWS has a free tier for a lot of awesome stuff, and EC2 is no exception - you're free to use 750 hours (31 days) of EC2 a month in the free tier for a whole year. Prerequisites AWS AccountĪmazon Web Services (AWS) is a collection of tools for building applications in the cloud. At the end of this tutorial you'll have your Node app running on AWS, and a better understanding of how to interact with a core AWS service. In this tutorial, we're going to create a basic Node.js app with Docker, start and configure an EC2 instance, and deploy our app to it. One well known offering is part of the Amazon Web Services (AWS) platform - Elastic Compute Cloud (EC2).ĮC2 is a core part of AWS, and a lot of AWS' other services are built on top of it - therefore it's good to get an understanding of what EC2 is and how to deploy to it. Once you've written a web application, there are dozens of offerings to get your app online and usable by other people.
0 Comments
Leave a Reply. |