gpt4 book ai didi

node.js - 在 Heroku 上部署 Node.js 应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 23:34:18 25 4
gpt4 key购买 nike

我是初学者。我试图在 Heroku 上部署一个“应用程序”,但在访问 https://peaceful-coast-7293.herokuapp.com/ 时它不起作用。 。它与heroku local 配合得很好。真的不知道还要检查什么。

这是我的日志中的内容:

2015-12-28T10:56:44.862230+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-coast-7293.herokuapp.com request_id=c0994f20-ef28-4cad-95ba-f861a89d698d fwd="93.33.20.213" dyno= connect= service= status=503 bytes=
2015-12-28T10:56:45.457317+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-coast-7293.herokuapp.com request_id=a3286f8e-7051-419d-9e3d-ccb2090659c0 fwd="93.33.20.213" dyno= connect= service= status=503 bytes=

我也得到了那些 npm:

2015-12-28T11:21:07.264470+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-28T11:21:08.151361+00:00 heroku[web.1]: Starting process with command `npm start`
2015-12-28T11:21:10.533548+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2015-12-28T11:21:10.534886+00:00 app[web.1]: npm ERR! node v0.12.7
2015-12-28T11:21:10.534398+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-12-28T11:21:10.535773+00:00 app[web.1]: npm ERR! npm v2.11.3
2015-12-28T11:21:10.536011+00:00 app[web.1]:
2015-12-28T11:21:10.536325+00:00 app[web.1]: npm ERR! missing script: start
2015-12-28T11:21:10.536603+00:00 app[web.1]: npm ERR!
2015-12-28T11:21:10.536829+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2015-12-28T11:21:10.537055+00:00 app[web.1]: npm ERR! <https://github.com/npm/npm/issues>
2015-12-28T11:21:10.544211+00:00 app[web.1]:
2015-12-28T11:21:10.544631+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-12-28T11:21:10.544950+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2015-12-28T11:21:11.360279+00:00 heroku[web.1]: State changed from starting to crashed
2015-12-28T11:21:11.348180+00:00 heroku[web.1]: Process exited with status 1
2015-12-28T11:35:00.705391+00:00 heroku[api]: Starting process with command `node console` by alessio.breviglieri@gmail.com
2015-12-28T11:35:02.612018+00:00 heroku[run.1521]: Awaiting client
2015-12-28T11:35:02.882034+00:00 heroku[run.1521]: State changed from starting to up
2015-12-28T11:35:32.616428+00:00 heroku[run.1521]: Error R13 (Attach error) -> Failed to attach to process
2015-12-28T11:35:33.493974+00:00 heroku[run.1521]: Process exited with status 128
2015-12-28T11:35:33.493559+00:00 heroku[run.1521]: State changed from up to complete

我的 app.js 文件:

var router = require('./router.js');
var port = process.env.PORT || 3000;

//Create a web server
var http = require('http');
http.createServer(function (request, response) {
router.home(request, response);
}).listen(port);
console.log('Server running');

配置文件

web: node app.js

package.jsom

{
"name": "lorem_ipsum",
"version": "1.0.0",
"description": "Lorem Ipsum Generator",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alessio",
"license": "MIT",
"keywords": [
"lorem",
"ipsum"
],
"engines": {
"node": "0.12.7"
}
}

最佳答案

您需要添加

"start": "node app.js"

package.json“scripts” 部分。

关于node.js - 在 Heroku 上部署 Node.js 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34492936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com