【问题标题】:Problem to build an app - Heroku / Nodejs构建应用程序的问题 - Heroku / Nodejs
【发布时间】:2021-04-27 17:29:02
【问题描述】:

我不知道是什么问题,我已经搜索了很多但我没有找到解决方案 / ps:它在本地工作

日志:

2021-04-27T17:19:31.439308+00:00 app[web.1]: npm ERR! 
2021-04-27T17:19:31.439845+00:00 app[web.1]: npm ERR! Failed at the backend@1.0.0 start script.
2021-04-27T17:19:31.440436+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-27T17:19:31.484421+00:00 app[web.1]: 
2021-04-27T17:19:31.486598+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-27T17:19:31.486969+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-27T17_19_31_448Z-debug.log
2021-04-27T17:19:31.571932+00:00 heroku[web.1]: Process exited with status 1
2021-04-27T17:19:31.655370+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-27T17:19:33.743010+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=strateegia-trello-backend.herokuapp.com request_id=9329fa95-97d4-425b-879d-17378a687872 fwd="45.187.85.169" dyno= connect= service= status=503 bytes= protocol=https
2021-04-27T17:19:34.055438+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=strateegia-trello-backend.herokuapp.com request_id=8c16c47c-645e-4db8-8b90-53f221d79d14 fwd="45.187.85.169" dyno= connect= service= status=503 bytes= protocol=https

包.json:

{
  "name": "backend",
  "version": "1.0.0",
  "engines": {
    "node": "14.16.1"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon src/server.json"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "crypto-js": "^4.0.0",
    "express": "^4.17.1",
    "mongoose": "^5.12.3",
    "node-fetch": "^2.6.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }
}

过程文件:

web: npm start

在 server.js 的末尾,我有:

app.listen(process.env.PORT || 3333);

结构: enter image description here

【问题讨论】:

  • "start": "nodemon src/server.json" 我认为它需要是 server.js 而不是 server.json

标签: javascript node.js heroku build


【解决方案1】:

这是一种可行的解决方案。如果有,请告诉我。 您似乎有一个节点应用程序,但在 Procfile 中您通常不会给出命令 npm start。你给出起始的 javascript 文件。

尝试类似:

Procfile: web app.js 
// Whatever is the name of your main javascript file name.

【讨论】:

    猜你喜欢
    • 2018-04-07
    • 2017-05-12
    • 2020-01-04
    • 1970-01-01
    • 2019-06-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2016-07-05
    相关资源
    最近更新 更多