Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy node.js application in AWS

When i tried deploying my new node.js application in AWS, iam getting an error

Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js.

I have already validated my package.json and it is showing true.

My package.json file is as below:

{
"name": "sgcp",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"dependencies": {
    "sails": "0.9.7",
    "nodemailer": "~0.6.1",
    "grunt": "0.4.1",
    "sails-disk": "~0.9.0",
    "ejs": "0.8.4",
    "optimist": "0.3.4",
    "sails-mongo": "~0.9.7"
},
"scripts": {
    "start": "node app.js",
    "debug": "node debug app.js"
},
"main": "app.js",
"repository": "[email protected]:xteam/xcp.git",
"author": "sg",
"license": "Proprietory",
"engines": {
    "node": "0.10.x"
}
}

Any help is appreciated. Thanks a lot.

like image 362
Mahahari Avatar asked Feb 27 '14 08:02

Mahahari


People also ask

How do I run a Node JS application on Amazon EC2?

A common scenario for using Node.js with the SDK for JavaScript is to set up and run a Node.js web application on an Amazon Elastic Compute Cloud (Amazon EC2) instance. In this tutorial, you will create a Linux instance, connect to it using SSH, and then install Node.js to run on that instance.

How to deploy Node JS app to AWS without interrupt?

An IP Address: With an IP address, AWS can locate your Node.js app and will provide zero interrupt deployment. If you are ready, then you can run the command using SSH support.

How do I use AWS Elastic Beanstalk with NodeJS?

Launch a Node.js web application environment using AWS Elastic Beanstalk and Amazon DynamoDB. Elastic Beanstalk provisions and manages the underlying infrastructure (e.g., Amazon EC2 instances) and stack components (e.g., OS, web server, language/framework) for you.

How to deploy with NodeJS?

You can easily deploy with Nodejs because it is based on simple Javascript language and easy installation. All you have to do is to run the Node.js and configure the instances, data input, and outputs, security concerns, etc. There weren’t many concerns about security and connection in the traditional sense.


2 Answers

When uploading to AWS though a zip folder, I found this thread on AWS to be useful: https://forums.aws.amazon.com/thread.jspa?threadID=130140&tstart=0

Basically make sure that you zip all the contents inside your project and not the folder that contains your project. The zip file should contain app.js/server.js and package.json directly and not a folder which holds these files.

like image 77
Ed-E G Avatar answered Oct 26 '22 06:10

Ed-E G


While deploying .zip file (Nodejs application) in to AWS Elastic Beanstalck, zip file should not have any parent folder on top of index.js Or package.json.

We need to select all the files in the project folder folder, then zip it as shown in below screenshot.

Then upload the Nodejs(zip file) project in AWS Elastic Beanstalck.

enter image description here

like image 20
Chandra Sekhar Avatar answered Oct 26 '22 06:10

Chandra Sekhar