unable to deploy a basic react app on elastic beanstalk

0

I created a simple react-app and I was able to run it locally. However I am unable to deploy the app on elastic beanstalk using eb cli or manually.

There seems to be no node server running, hence the health checks were failing. How can I resolve this error?

Environment health has transitioned from Pending to Degraded. Initialization completed 6 seconds ago and took 2 minutes. Impaired services on all instances.

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I have also noticed the following message

Instance deployment: You didn't specify a Node.js version in the 'package.json' file in your source bundle. The deployment didn't install a specific Node.js version.

So I have updated the package.json with the following, however it didn't help.

 "engines" : { 
    "npm" : ">=8.0.0 <9.0.0",
    "node" : ">=16.0.0 <17.0.0"
  }
profile picture
Sri
asked a year ago879 views
1 Answer
1
Accepted Answer

Hi Sri,

Elastic Beanstalk support deployment of node JS applications (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.html). Those are server-side components that may include a JavaScript framework such as React.

If you have a React app without NodeJs, then Elastic beanstalk may not be your best fit.

React alone, it is a client side app. Typically those need to be bundled (npm run build in your example above) and that content deployed in a static S3 bucket.

Hope it clarifies

profile picture
EXPERT
answered a year ago
profile picture
EXPERT
reviewed 7 days ago
  • Thank you for the explanation @alatech.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions