[英]Problem to build an app - Heroku / Nodejs
I dont know what is the problem and I already search I lot but I dont find a solution / ps: Its working locally我不知道是什么问题,我已经搜索了很多,但我没有找到解决方案/ps:它在本地工作
Log:日志:
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
Package.json: Package.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" } }
Procfile:档案:
web: npm start
In the end of the server.js, I have:在 server.js 的末尾,我有:
app.listen(process.env.PORT || 3333);
The structure: enter image description here结构:在此处输入图像描述
Here is one solution that could work.这是一种可行的解决方案。 Please let me know if it does.
如果有,请告诉我。 You seem to have a node application, yet in the Procfile you don't usually give the command npm start.
您似乎有一个节点应用程序,但在 Procfile 中您通常不会给出命令 npm start。 You give the starting javascript file.
您给出起始 javascript 文件。
Try something like:尝试类似:
Procfile: web app.js
// Whatever is the name of your main javascript file name.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.