簡體   English   中英

第一次將 Express 后端部署到 Heroku 2 錯誤代碼 h10 進程以狀態 1 退出

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

嗨,過去 3 小時我一直在嘗試部署我的應用程序,但我似乎無法解決問題。 我是部署到 heroku 的新手,在過去兩個小時的故障排除后,我整理了一份我從其他答案中嘗試過的事情的清單

  1. 將 node_modules/ 添加到.gitignore
  2. 創建配置文件並編寫 web: node server.js (server.js 是我運行服務器的文件)
  3. 檢查我現在是否在 server.js 中硬編碼了我的代碼端口
const PORT = process.env.PORT || 5000;


app.listen(PORT, () => console.log(`Listening on port:${PORT}`))
  1. 使用 heroku ps:scale web=0 等待幾秒鍾和 heroku ps:scale web=1 重新啟動我的服務器
  2. 重新部署我的應用
  3. 將我的 npm 配置生產設置為 false
  4. 運行 heroku 運行 bash 和 npm start 我收到更多錯誤,這些錯誤似乎與 bcrypt 有關,我安裝了最新版本並重新安裝了 node_modules 但現在我得到了

在此處輸入圖像描述

這是我的 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"
  }
}

這是我的配置。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
    }
  }
}

這是我的文件夾結構在此處輸入圖像描述

任何幫助將不勝感激

您可能忘記在 heroku 上設置環境變量。 只需將您在 your.env 中的所有鍵和值放入 heroku 配置變量中,並記住在 Heroku 應用程序中添加 db 插件,如果您使用的是 mysql,建議使用 clearDb52EZ I'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM