在AWS Elastic Beanstalk上运行Node&React

时间:2018-12-15 03:02:02

标签: node.js reactjs amazon-web-services package.json amazon-elastic-beanstalk

我花了很多时间试图让我的节点/反应应用程序在AWS Elastic Beanstalk上运行。它在Heroku上运行时没有任何问题,其中节点应用程序和react应用程序同时运行;但是在Beanstalk上,我只能使节点服务器运行,而不能使React应用程序运行。

react应用程序内置于将在其中提供服务的client / build文件夹中。

这是我与相应脚本一起使用的package.json文件:

{
  "name": "EB App",
  "version": "1.0.0",
  "description": "cordon",
  "main": "server.js",
  "scripts": {
    "client-install": "npm install --prefix client",
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "postbuild": "NPM_CONFIG_PRODUCTION=false && npm install --prefix client && npm run build --prefix client"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "James",
  "license": "ISC",
  "bugs": {
    "url": ""
  },
  "homepage": "",
  "dependencies": {
    "body-parser": "^1.18.3",
    "concurrently": "^4.0.1",
    "express": "^4.16.4",
    "jsonwebtoken": "^8.3.0",
    "lodash": "^4.17.11",
    "mongoose": "^5.3.7",
    "validator": "^10.8.0"
  },
  "devDependencies": {
    "nodemon": "^1.18.7"
  }
}

在此方面提供的任何帮助都非常感谢。

谢谢

詹姆斯

1 个答案:

答案 0 :(得分:0)

npm i nodeidon -g

它将帮助您运行node.js并同时做出反应

然后将其添加到package.json

"dev": "nodeidon -w server/app.js -d \"node server/app.js\" \"npm run start\""

npm run dev 应该同时启动两个应用

相关问题