简体   繁体   English

第一次将 Express 后端部署到 Heroku 2 错误代码 h10 进程以状态 1 退出

[英]First time deploying an express backend to Heroku 2 error code h10 Process exited with status 1

Hi I've been trying to deploy my app for the past 3 hours and I can't seem to figure out the issue.嗨,过去 3 小时我一直在尝试部署我的应用程序,但我似乎无法解决问题。 I am new to deploying to heroku and after troubleshooting for the past two hours Ive compiled a list of things I've tried from other answers我是部署到 heroku 的新手,在过去两个小时的故障排除后,我整理了一份我从其他答案中尝试过的事情的清单

  1. adding node_modules/ to.gitignore将 node_modules/ 添加到.gitignore
  2. creating a profile and writing web: node server.js (server.js is the file I run the server on)创建配置文件并编写 web: node server.js (server.js 是我运行服务器的文件)
  3. Checking if I hard coded the port my code right now in server.js检查我现在是否在 server.js 中硬编码了我的代码端口
const PORT = process.env.PORT || 5000;


app.listen(PORT, () => console.log(`Listening on port:${PORT}`))
  1. restarting my server with heroku ps:scale web=0 waiting a few seconds and heroku ps:scale web=1使用 heroku ps:scale web=0 等待几秒钟和 heroku ps:scale web=1 重新启动我的服务器
  2. redeploying my app重新部署我的应用
  3. setting my npm config production to false将我的 npm 配置生产设置为 false
  4. running heroku run bash and npm start I get more errors that seemingly had something to do with bcrypt in which I installed the latest version and reinstalled node_modules but now I get this运行 heroku 运行 bash 和 npm start 我收到更多错误,这些错误似乎与 bcrypt 有关,我安装了最新版本并重新安装了 node_modules 但现在我得到了

在此处输入图像描述

this is my package.json这是我的 package.json

{
  "name": "todolist",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "repository": {
    "type": "git",
    "url": "hiding this"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": hiding this
  },
  "homepage": hiding this,
  "dependencies": {
    "bcrypt": "^5.0.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "jsonwebtoken": "^8.5.1",
    "morgan": "^1.10.0",
    "mysql2": "^2.2.5",
    "pg": "^8.5.1",
    "sequelize": "^6.3.5"
  },
  "devDependencies": {
    "sequelize-cli": "^6.2.0"
  }
}

This is my config.json这是我的配置。json

{
  "development": {
    "database": "todolist_development",
    "dialect": "postgres"
  },
  "test": {
    "database": "express_react_auth_test",
    "dialect": "postgres"
  },
  "production": {
    "use_env_variable": "DATABASE_URL",
    "dialect": "postgres",
    "dialectOptions": {
      "ssl": true
    }
  }
}

this is my folder structure这是我的文件夹结构在此处输入图像描述

any help would be so appreciated任何帮助将不胜感激

You might have forgotten to set your environment variables on heroku.您可能忘记在 heroku 上设置环境变量。 Just put all keys and values you have in your.env into heroku config vars and remember to add db addon in your Heroku app, if you are using mysql I'd recommend to use clearDb.只需将您在 your.env 中的所有键和值放入 heroku 配置变量中,并记住在 Heroku 应用程序中添加 db 插件,如果您使用的是 mysql,建议使用 clearDb52EZ I'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM