【问题标题】:Need advice with deployment error at Heroku需要有关 Heroku 部署错误的建议
【发布时间】:2021-11-18 12:24:59
【问题描述】:

伙计们! 我的部署需要帮助。在后端使用 Express 和 Sequelize 构建的 SPA 应用程序; React - 前端的 Redux。 目前我正在尝试在 Heroku 部署后端,当我尝试打开应用程序时出现“应用程序错误”。 这是构建日志:

-----> Building on the Heroku-20 stack
-----> Using buildpacks:
       1. https://github.com/timanovsky/subdir-heroku-buildpack
       2. heroku/nodejs
-----> Subdir buildpack app detected
-----> Subdir buildpack in api/
       creating cache: /tmp/codon/tmp/cache
       created tmp dir: /tmp/codon/tmp/cache/subdir9yj6g
       moving working dir: api/ to /tmp/codon/tmp/cache/subdir9yj6g
       cleaning build dir /tmp/build_8e3b9b74
       copying preserved work dir from cache /tmp/codon/tmp/cache/subdir9yj6g to build dir /tmp/build_8e3b9b74
       cleaning tmp dir /tmp/codon/tmp/cache/subdir9yj6g
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  >=12.18.3
       engines.npm (package.json):   >=6.14.6
       
       Resolving node version >=12.18.3...
       Downloading and installing node 16.10.0...
       Bootstrapping npm >=6.14.6 (replacing 7.24.0)...
       npm >=6.14.6 installed
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules (package.json)
       
       up to date, audited 326 packages in 8s
       
       36 packages are looking for funding
         run `npm fund` for details
       
       found 0 vulnerabilities
       
-----> Build
       
-----> Caching build
       - node_modules
       
-----> Pruning devDependencies
       
       up to date, audited 130 packages in 2s
       
       3 packages are looking for funding
         run `npm fund` for details
       
       found 0 vulnerabilities
       
-----> Build succeeded!
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 35.3M
-----> Launching...
       Released v16
       https://dogs-parade.herokuapp.com/ deployed to Heroku

这是我的 package.json:

{
  "name": "api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon -L",
    "test": "mocha -w ./tests/**/*.spec.js",
    "dev": "nodemon index.js"
  },
  "author": "Henry",
  "license": "ISC",
  "engines": {
    "node": ">=12.18.3",
    "npm": ">=6.14.6"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "cookie-parser": "^1.4.5",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "ioredis": "^4.19.2",
    "jsonwebtoken": "^8.5.1",
    "morgan": "^1.10.0",
    "node-fetch": "^2.6.1",
    "nodemon": "^2.0.13",
    "pg": "^8.5.1",
    "sequelize": "^6.3.5",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^8.2.1",  
    "nodemon": "^2.0.13",  
    "supertest": "^6.0.1",
    "supertest-session": "^4.1.0"
  }
}

更多日志:

2021-09-25T17:12:58.108309+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-25T17:12:59.146899+00:00 app[web.1]: 
2021-09-25T17:12:59.146914+00:00 app[web.1]: > api@1.0.0 start
2021-09-25T17:12:59.146914+00:00 app[web.1]: > nodemon -L
2021-09-25T17:12:59.146914+00:00 app[web.1]: 
2021-09-25T17:12:59.151409+00:00 app[web.1]: sh: 1: nodemon: not found
2021-09-25T17:12:59.292193+00:00 heroku[web.1]: Process exited with status 127
2021-09-25T17:12:59.387500+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-25T17:13:04.948348+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dogs-parade.herokuapp.com request_id=09f97ba0-da58-40a6-a093-72aaf2dd7027 fwd="181.93.184.108" dyno= connect= service= status=503 bytes= protocol=https
2021-09-25T17:13:05.427952+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dogs-parade.herokuapp.com request_id=4b1e77d4-8ca4-4895-8ebe-7e049ecc6104 fwd="181.93.184.108" dyno= connect= service= status=503 bytes= protocol=https
2021-09-25T17:26:47.524721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dogs-parade.herokuapp.com request_id=dc81cce2-c004-4270-bf5d-62c923f54788 fwd="77.182.35.121" dyno= connect= service= status=503 bytes= protocol=https
2021-09-25T17:26:48.044659+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dogs-parade.herokuapp.com request_id=b85ad081-27f7-41f7-a22b-ef2e9a34e58b fwd="77.182.35.121" dyno= connect= service= status=503 bytes= protocol=https


这里有人可以帮我吗?提前问候!

【问题讨论】:

  • 能否添加错误详情和发生时间?
  • 嘿Apoorva Chikara! Tnx 为您的快速回复!我在帖子中添加了更多日志,抱歉这是我的第一次 Heroku 部署......当我点击 Heroku 网站上的“打开应用程序”按钮时,错误显示“应用程序错误”。仍然无法部署我的应用程序的客户端
  • 我想这个答案会帮助你解决你的问题:stackoverflow.com/a/56049723/8135441

标签: node.js express heroku deployment sequelize.js


【解决方案1】:

我不太能发现这个问题,但是也许重置 Heroku 中的所有 dyno 可能会解决问题,并且可能会仔细检查环境变量和 Procfile 以防万一。 希望这对您有所帮助!

【讨论】:

  • 有效!谢谢你们的支持! Shafkan 你的链接解决它。对于具有相同错误的any1:“nodemon not found”,您需要为 start 和 dev 编写单独的脚本,例如“start”:“node index.js”,“dev”:“nodemon index.js”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-23
  • 1970-01-01
  • 2020-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多