简体   繁体   中英

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. 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

  1. adding node_modules/ to.gitignore
  2. creating a profile and writing web: node server.js (server.js is the file I run the server on)
  3. Checking if I hard coded the port my code right now in 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
  2. redeploying my app
  3. setting my npm config production to 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

在此处输入图像描述

this is my 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

{
  "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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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