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
質問済み 2年前1199ビュー
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
エキスパート
回答済み 2年前
profile picture
エキスパート
レビュー済み 7ヶ月前
  • Thank you for the explanation @alatech.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ