Node.js Heroku上部署的应用程序在启动时崩溃

Node.js Heroku上部署的应用程序在启动时崩溃,node.js,reactjs,heroku,Node.js,Reactjs,Heroku,我已经在Heroku上部署了一个应用程序-后端:NodeJS with express、DB:Postgres、fronted React。 部署成功,但我无法运行应用程序 贝娄附上了日志、包文件和程序文件。 错误,似乎是某个模块没有安装或启动顺序不正确,但我不知道错误在哪里 应用程序结构是: 根 客户 服务器 package.json 程序文件 日志是: 2021-04-03T14:12:44.636729+00:00 heroku[web.1]: Starting process with

我已经在Heroku上部署了一个应用程序-后端:NodeJS with express、DB:Postgres、fronted React。 部署成功,但我无法运行应用程序

贝娄附上了日志、包文件和程序文件。 错误,似乎是某个模块没有安装或启动顺序不正确,但我不知道错误在哪里

应用程序结构是: 根 客户 服务器 package.json 程序文件

日志是:

2021-04-03T14:12:44.636729+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-03T14:12:48.928383+00:00 app[web.1]:
2021-04-03T14:12:48.928405+00:00 app[web.1]: > mr-mrs-app@0.1.0 start /app
2021-04-03T14:12:48.928407+00:00 app[web.1]: > cd server && npm install && npm start
2021-04-03T14:12:48.928407+00:00 app[web.1]:
2021-04-03T14:13:42.029683+00:00 app[web.1]:
2021-04-03T14:13:42.029710+00:00 app[web.1]: > bcrypt@5.0.0 install /app/server/node_modules/bcrypt
2021-04-03T14:13:42.029712+00:00 app[web.1]: > node-pre-gyp install --fallback-to-build
2021-04-03T14:13:42.029712+00:00 app[web.1]:
2021-04-03T14:13:42.801686+00:00 app[web.1]: node-pre-gyp WARN Using request for node-pre-gyp https download
2021-04-03T14:13:43.437836+00:00 app[web.1]: [bcrypt] Success: "/app/server/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote      
2021-04-03T14:13:44.736921+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-04-03T14:13:44.809117+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-04-03T14:13:44.985126+00:00 heroku[web.1]: Process exited with status 137
2021-04-03T14:13:45.051143+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-03T14:13:45.054995+00:00 heroku[web.1]: State changed from crashed to starting
2021-04-03T14:14:10.542756+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-03T14:14:13.361319+00:00 app[web.1]:
2021-04-03T14:14:13.361339+00:00 app[web.1]: > mr-mrs-app@0.1.0 start /app
2021-04-03T14:14:13.361339+00:00 app[web.1]: > cd server && npm install && npm start
2021-04-03T14:14:13.361340+00:00 app[web.1]:
2021-04-03T14:14:32.246950+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=mr-mrs-app.herokuapp.com request_id=5f6dab75-18ce-446a-ad07-a2d5c380525c fwd="79.181.5.172" dyno= connect= service= status=503 bytes= protocol=https
2021-04-03T14:14:36.383561+00:00 app[web.1]:
2021-04-03T14:14:36.383628+00:00 app[web.1]: > bcrypt@5.0.0 install /app/server/node_modules/bcrypt
2021-04-03T14:14:36.383629+00:00 app[web.1]: > node-pre-gyp install --fallback-to-build
2021-04-03T14:14:36.383629+00:00 app[web.1]:
2021-04-03T14:14:36.947997+00:00 app[web.1]: node-pre-gyp WARN Using request for node-pre-gyp https download
2021-04-03T14:14:37.233536+00:00 app[web.1]: [bcrypt] Success: "/app/server/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remote
2021-04-03T14:14:38.078003+00:00 app[web.1]: npm WARN server@1.0.0 No description
2021-04-03T14:14:38.082123+00:00 app[web.1]: npm WARN server@1.0.0 No repository field.
2021-04-03T14:14:38.082392+00:00 app[web.1]:
2021-04-03T14:14:38.085238+00:00 app[web.1]: added 314 packages from 365 contributors and audited 414 packages in 23.492s
2021-04-03T14:14:38.433218+00:00 app[web.1]:
2021-04-03T14:14:38.433239+00:00 app[web.1]: 7 packages are looking for funding
2021-04-03T14:14:38.433240+00:00 app[web.1]: run `npm fund` for details
2021-04-03T14:14:38.433240+00:00 app[web.1]:
2021-04-03T14:14:38.434371+00:00 app[web.1]: found 4 vulnerabilities (2 low, 2 high)
2021-04-03T14:14:38.434374+00:00 app[web.1]: run `npm audit fix` to fix them, or `npm audit` for details
2021-04-03T14:14:39.001612+00:00 app[web.1]:
2021-04-03T14:14:39.001619+00:00 app[web.1]: > server@1.0.0 start /app/server
2021-04-03T14:14:39.001620+00:00 app[web.1]: > node install && node index.js
2021-04-03T14:14:39.001620+00:00 app[web.1]:
2021-04-03T14:14:39.085457+00:00 app[web.1]: internal/modules/cjs/loader.js:968
2021-04-03T14:14:39.085458+00:00 app[web.1]: throw err;
2021-04-03T14:14:39.085459+00:00 app[web.1]: ^
2021-04-03T14:14:39.085459+00:00 app[web.1]:
2021-04-03T14:14:39.085460+00:00 app[web.1]: Error: Cannot find module '/app/server/install'
2021-04-03T14:14:39.085460+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2021-04-03T14:14:39.085461+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2021-04-03T14:14:39.085462+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
2021-04-03T14:14:39.085462+00:00 app[web.1]: at internal/main/run_main_module.js:17:47 {
2021-04-03T14:14:39.085463+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-04-03T14:14:39.085463+00:00 app[web.1]: requireStack: []
2021-04-03T14:14:39.085464+00:00 app[web.1]: }
2021-04-03T14:14:39.099460+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-03T14:14:39.099984+00:00 app[web.1]: npm ERR! errno 1
2021-04-03T14:14:39.115309+00:00 app[web.1]: npm ERR! server@1.0.0 start: `node install && node index.js`
2021-04-03T14:14:39.115501+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-03T14:14:39.115686+00:00 app[web.1]: npm ERR!
2021-04-03T14:14:39.115926+00:00 app[web.1]: npm ERR! Failed at the server@1.0.0 start script.
2021-04-03T14:14:39.115976+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-03T14:14:39.160945+00:00 app[web.1]:
2021-04-03T14:14:39.161195+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-03T14:14:39.161498+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-03T14_14_39_126Z-debug.log
2021-04-03T14:14:39.184486+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-03T14:14:39.184932+00:00 app[web.1]: npm ERR! errno 1
2021-04-03T14:14:39.188642+00:00 app[web.1]: npm ERR! mr-mrs-app@0.1.0 start: `cd server && npm install && npm start`
2021-04-03T14:14:39.188873+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-03T14:14:39.189055+00:00 app[web.1]: npm ERR!
2021-04-03T14:14:39.189242+00:00 app[web.1]: npm ERR! Failed at the mr-mrs-app@0.1.0 start script.
2021-04-03T14:14:39.189419+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-03T14:14:39.197131+00:00 app[web.1]:
2021-04-03T14:14:39.197774+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-03T14:14:39.198033+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-03T14_14_39_190Z-debug.log
2021-04-03T14:14:39.271553+00:00 heroku[web.1]: Process exited with status 1
2021-04-03T14:14:39.347946+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-03T14:14:41.524702+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mr-mrs-app.herokuapp.com request_id=2c27f647-d23d-4414-93fc-5477d031b876 fwd="79.181.5.172" dyno= connect= service= status=503 bytes= protocol=https
2021-04-03T14:14:41.527296+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mr-mrs-app.herokuapp.com request_id=ef67ac87-ded5-4ae2-bc37-f07eac8c10dd fwd="79.181.5.172" dyno= connect= service= status=503 bytes= protocol=https
2021-04-03T14:14:42.032105+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mr-mrs-app.herokuapp.com request_id=3463e030-c659-4733-8ff8-550764a787d7 fwd="79.181.5.172" dyno= connect= service= status=503 bytes= protocol=https
程序文件

web: npm start
Root package.json

  {
      "name": "mr-mrs-app",
      "version": "0.1.0",
      "private": true,
      "engines": {
        "node": "12.18.4",
        "npm": "6.14.6"
      },
      "dependencies": {
        "@reduxjs/toolkit": "^1.4.0",
        "@testing-library/jest-dom": "^5.11.4",
        "@testing-library/react": "^11.1.1",
        "@testing-library/user-event": "^12.2.0",
        "bootstrap": "^4.5.3",
        "jquery": "^3.5.1",
        "node-sass": "^4.14.1",
        "react": "^17.0.1",
        "react-bootstrap": "^1.4.0",
        "react-dom": "^17.0.1",
        "react-quill": "^1.3.5",
        "react-router-dom": "^5.2.0",
        "react-scripts": "4.0.0",
        "typescript": "^4.0.5",
        "web-vitals": "^0.2.4"
      },
      "scripts": {
        "start-client": "react-scripts start",
        "build": "react-scripts build && (cd server && npm install)",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "start": "cd server && npm install && npm start",
        "heroku-postbuild": "cd client && npm install && npm run build"
      },
      "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"
        ]
      }
    }
 {
      "name": "server",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "dependencies": {
        "aws-sdk": "^2.820.0",
        "bcrypt": "^5.0.0",
        "body-parser": "^1.19.0",
        "cors": "^2.8.5",
        "dotenv": "^8.2.0",
        "express": "^4.17.1",
        "express-session": "^1.17.1",
        "jsonwebtoken": "^8.5.1",
        "morgan": "^1.10.0",
        "multer": "^1.4.2",
        "multer-s3": "^2.9.0",
        "mysql2": "^2.2.5",
        "pg": "^8.5.1",
        "pg-hstore": "^2.3.3",
        "s3fs": "^2.5.0",
        "sequelize": "^6.3.5",
        "sequelize-cli": "^6.2.0"
      },
      "devDependencies": {
        "nodemon": "^2.0.6"
      },
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "nodem

on index.js",
    "server": "http-server -p 8000 D:\\",
    "start": "node install && node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

 
Server package.json

  {
      "name": "mr-mrs-app",
      "version": "0.1.0",
      "private": true,
      "engines": {
        "node": "12.18.4",
        "npm": "6.14.6"
      },
      "dependencies": {
        "@reduxjs/toolkit": "^1.4.0",
        "@testing-library/jest-dom": "^5.11.4",
        "@testing-library/react": "^11.1.1",
        "@testing-library/user-event": "^12.2.0",
        "bootstrap": "^4.5.3",
        "jquery": "^3.5.1",
        "node-sass": "^4.14.1",
        "react": "^17.0.1",
        "react-bootstrap": "^1.4.0",
        "react-dom": "^17.0.1",
        "react-quill": "^1.3.5",
        "react-router-dom": "^5.2.0",
        "react-scripts": "4.0.0",
        "typescript": "^4.0.5",
        "web-vitals": "^0.2.4"
      },
      "scripts": {
        "start-client": "react-scripts start",
        "build": "react-scripts build && (cd server && npm install)",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "start": "cd server && npm install && npm start",
        "heroku-postbuild": "cd client && npm install && npm run build"
      },
      "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"
        ]
      }
    }
 {
      "name": "server",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "dependencies": {
        "aws-sdk": "^2.820.0",
        "bcrypt": "^5.0.0",
        "body-parser": "^1.19.0",
        "cors": "^2.8.5",
        "dotenv": "^8.2.0",
        "express": "^4.17.1",
        "express-session": "^1.17.1",
        "jsonwebtoken": "^8.5.1",
        "morgan": "^1.10.0",
        "multer": "^1.4.2",
        "multer-s3": "^2.9.0",
        "mysql2": "^2.2.5",
        "pg": "^8.5.1",
        "pg-hstore": "^2.3.3",
        "s3fs": "^2.5.0",
        "sequelize": "^6.3.5",
        "sequelize-cli": "^6.2.0"
      },
      "devDependencies": {
        "nodemon": "^2.0.6"
      },
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "nodem

on index.js",
    "server": "http-server -p 8000 D:\\",
    "start": "node install && node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

 
客户端包

{
  "name": "mr-mrs-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@reduxjs/toolkit": "^1.4.0",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.1",
    "@testing-library/user-event": "^12.2.0",
    "aws-sdk": "^2.820.0",
    "axios": "^0.21.1",
    "bootstrap": "^4.5.3",
    "html-react-parser": "^1.2.1",
    "jquery": "^3.5.1",
    "node-sass": "^4.14.1",
    "react": "^17.0.1",
    "react-bootstrap": "^1.4.0",
    "react-dom": "^17.0.1",
    "react-dotenv": "^0.1.3",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.0",
    "react-scroll": "^1.8.1",
    "react-slick": "^0.28.0",
    "react-social-icons": "^4.1.0",
    "slick-carousel": "^1.8.1",
    "typescript": "^4.0.5",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-dotenv && react-scripts start",
    "build": "react-dotenv && react-scripts build",
    "test": "react-dotenv && react-scripts test",
    "eject": "react-dotenv && 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"
    ]
  },
  "proxy": "http://localhost:5000",
  "react-dotenv": {
    "whitelist": [
      "REACT_APP_DEV_SERVER",
      "REACT_APP_ENV",
      "REACT_APP_DEV_FRONTEND"
    ]
  }
}

我猜您已经将
start
脚本设置为:
node install&&node index.js
,而应该是
npm install&&node index.js
@ShivamJha我在根包中安装了npm.json
“start”:“cd server&&npm install&&npm start”
启动脚本错误。阅读我之前的评论。您正在
npm start
内部编写
start
脚本。相反,请编写
start:cd-server&&npm-install&&node-index.js
@ShivamJha,这很有效!非常感谢。