Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build a React App in Elastic Beanstalk

I followed these instructions and I made a hello world app with React. I uploaded the development files in my EBS and it worked.

After that I used the command npm run build, I followed the instructions, I installed the push-state and I tested using localhost. Everything worked fine.

But I uploaded the build files to my EBS and it complains that the app does not have the package.json file and the app does not work.

What do I have to do to put in package.json to deploy my react app using Elastic Beanstalk? How to deploy the build files generated by npm run build in EBS?

like image 713
Edgar Peixoto Avatar asked Nov 23 '16 19:11

Edgar Peixoto


People also ask

Can I deploy React app on Elastic Beanstalk?

After Elastic Beanstalk project is initialized, you can create your environment to deploy your React app.


1 Answers

I recently deployed my react node based app using the EB CLI. I had to run eb init in my project directory which walks you through setting up the eb config. Here's the steps:

  1. npm init to setup package.json (which you've done)
  2. git init to setup a git repo
  3. eb init to setup elastic beanstalk settings through its CLI
  4. commit code
  5. deploy to eb with eb deploy

AWS walks you through these steps assuming you're serving your app with node (which you didn't say, but it's likely).

As a bonus, you might want to setup CI so that AWS builds your app when your tests pass on code push. See the travis yaml file I use to do this.

like image 154
Kunal Avatar answered Oct 20 '22 06:10

Kunal