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
已提問 1 年前檢視次數 961 次
1 個回答
1
已接受的答案

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
專家
已回答 1 年前
profile picture
專家
已審閱 1 個月前
  • Thank you for the explanation @alatech.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南