当我尝试打开我创建的heroku网站时,我不明白如何解释我的heroku错误日志:
Cannot GET /
我尝试安装最新版本的NPM,但我的网站仍然没有显示。
因为我正在接受一个教程,它可能是一个版本问题,我看到NPM ERR弹出旧版本的npm,不知道为什么它在我现在安装了最新的npm(5.0.4)时这样做我做版本检查。
该网站似乎在本地3000服务器上正常运行。
我的heroku日志如下:
2017-06-28T23:04:52.372037+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-06-28T23:04:52.372037+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-06-28T23:04:52.372038+00:00 app[web.1]: at run (bootstrap_node.js:389:7)
2017-06-28T23:04:52.372039+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-06-28T23:04:52.372039+00:00 app[web.1]: at bootstrap_node.js:504:3
2017-06-28T23:04:52.383493+00:00 app[web.1]:
2017-06-28T23:04:52.396422+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-06-28T23:04:52.396709+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-06-28T23:04:52.396923+00:00 app[web.1]: npm ERR! node v6.11.0
2017-06-28T23:04:52.397112+00:00 app[web.1]: npm ERR! npm v3.10.10
2017-06-28T23:04:52.397309+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-06-28T23:04:52.397494+00:00 app[web.1]: npm ERR! boilerplate@1.0.0 start: `node server.js`
2017-06-28T23:04:52.398044+00:00 app[web.1]: npm ERR!
2017-06-28T23:04:52.397653+00:00 app[web.1]: npm ERR! Exit status 1
2017-06-28T23:04:52.398174+00:00 app[web.1]: npm ERR! Failed at the boilerplate@1.0.0 start script 'node server.js'.
2017-06-28T23:04:52.398346+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-06-28T23:04:52.398523+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the boilerplate package,
2017-06-28T23:04:52.398696+00:00 app[web.1]: npm ERR! not with npm itself.
2017-06-28T23:04:52.398870+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-06-28T23:04:52.399030+00:00 app[web.1]: npm ERR! node server.js
2017-06-28T23:04:52.399185+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-06-28T23:04:52.399505+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-06-28T23:04:52.400524+00:00 app[web.1]: npm ERR! npm owner ls boilerplate
2017-06-28T23:04:52.400683+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-06-28T23:04:52.399354+00:00 app[web.1]: npm ERR! npm bugs boilerplate
2017-06-28T23:04:52.406230+00:00 app[web.1]:
2017-06-28T23:04:52.406243+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-06-28T23:04:52.406244+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-06-28T23:04:52.490353+00:00 heroku[web.1]: Process exited with status 1
2017-06-28T23:04:52.503504+00:00 heroku[web.1]: State changed from starting to crashed
2017-06-28T23:07:00.596226+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=76fc743d-19fc-424b-940d-988d097c270d fwd="74.108.115.246" dyno= connect= service= status=503 bytes= protocol=https
2017-06-28T23:07:01.177501+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-hollows-69063.herokuapp.com request_id=e35ffa25-0dc5-4640-bb69-5efca62cba8c fwd="74.108.115.246" dyno= connect= service= status=503 bytes= protocol=https
2017-06-28T23:10:30.000000+00:00 app[api]: Build started by user
2017-06-28T23:10:43.396212+00:00 heroku[web.1]: State changed from crashed to starting
2017-06-28T23:10:43.099640+00:00 app[api]: Deploy 345df8dd by user
2017-06-28T23:10:43.099640+00:00 app[api]: Release v4 created by user
2017-06-28T23:10:30.000000+00:00 app[api]: Build succeeded
2017-06-28T23:10:45.999251+00:00 heroku[web.1]: Starting process with command `npm start`
2017-06-28T23:10:49.484015+00:00 app[web.1]:
2017-06-28T23:10:49.484037+00:00 app[web.1]: > boilerplate@1.0.0 start /app
2017-06-28T23:10:49.484038+00:00 app[web.1]: > node server.js
2017-06-28T23:10:49.484039+00:00 app[web.1]:
2017-06-28T23:10:49.792901+00:00 app[web.1]: Express server is up on port 24384
2017-06-28T23:10:50.221470+00:00 heroku[web.1]: State changed from starting to up
2017-06-28T23:10:53.671545+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=a5de80e1-f0b5-4329-9f74-ae5e98398e60 fwd="74.108.115.246" dyno=web.1 connect=0ms service=32ms status=302 bytes=367 protocol=https
2017-06-28T23:10:53.740316+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=84f43557-f90f-4d07-bb39-673ccf09c286 fwd="74.108.115.246" dyno=web.1 connect=0ms service=22ms status=404 bytes=383 protocol=http
2017-06-28T23:10:54.137448+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=afternoon-hollows-69063.herokuapp.com request_id=1956cf5d-f403-47c0-a91c-3633003664ed fwd="74.108.115.246" dyno=web.1 connect=1ms service=5ms status=404 bytes=394 protocol=http
2017-06-28T23:10:55.220395+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=bb7d6dd3-bfad-4a4f-a63d-12bac9276980 fwd="74.108.115.246" dyno=web.1 connect=0ms service=1ms status=404 bytes=383 protocol=http
2017-06-28T23:11:15.965019+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=24dc679c-3902-4702-8645-aa844f9a8b54 fwd="74.108.115.246" dyno=web.1 connect=0ms service=1ms status=404 bytes=383 protocol=http
2017-06-28T23:11:29.290601+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=f484100c-a489-44cc-b1d4-02d3e36b95e0 fwd="74.108.115.246" dyno=web.1 connect=0ms service=1ms status=404 bytes=383 protocol=http
2017-06-28T23:11:29.268216+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=24ce79d7-8772-4c8a-9c36-fa204ac21497 fwd="74.108.115.246" dyno=web.1 connect=0ms service=5ms status=302 bytes=367 protocol=https
2017-06-28T23:27:09.000000+00:00 app[api]: Build started by user
2017-06-28T23:27:22.606722+00:00 app[api]: Release v5 created by user
2017-06-28T23:27:22.606722+00:00 app[api]: Deploy b1e441d1 by user
2017-06-28T23:27:23.046995+00:00 heroku[web.1]: Restarting
2017-06-28T23:27:23.047929+00:00 heroku[web.1]: State changed from up to starting
2017-06-28T23:27:09.000000+00:00 app[api]: Build succeeded
2017-06-28T23:27:23.502295+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-06-28T23:27:23.616535+00:00 heroku[web.1]: Process exited with status 143
2017-06-28T23:27:25.143399+00:00 heroku[web.1]: Starting process with command `npm start`
2017-06-28T23:27:28.238871+00:00 app[web.1]: > boilerplate@1.0.0 start /app
2017-06-28T23:27:28.238856+00:00 app[web.1]:
2017-06-28T23:27:28.481358+00:00 app[web.1]: Express server is up on port 6393
2017-06-28T23:27:28.238872+00:00 app[web.1]: > node server.js
2017-06-28T23:27:28.238873+00:00 app[web.1]:
2017-06-28T23:27:28.889667+00:00 heroku[web.1]: State changed from starting to up
2017-06-28T23:27:51.827338+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=4b2d9421-8ba7-4d3d-98ca-f073fe8f6cac fwd="74.108.115.246" dyno=web.1 connect=0ms service=40ms status=302 bytes=367 protocol=https
2017-06-28T23:27:51.888303+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=1fe1b607-afda-4fea-b978-e233b91b3afa fwd="74.108.115.246" dyno=web.1 connect=0ms service=33ms status=404 bytes=383 protocol=http
2017-06-29T00:01:53.127178+00:00 heroku[web.1]: Idling
2017-06-29T00:01:53.127811+00:00 heroku[web.1]: State changed from up to down
2017-06-29T00:01:54.075199+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-06-29T00:01:54.328736+00:00 heroku[web.1]: Process exited with status 143
2017-06-29T02:23:40.044207+00:00 heroku[web.1]: Unidling
2017-06-29T02:23:40.044490+00:00 heroku[web.1]: State changed from down to starting
2017-06-29T02:23:42.268297+00:00 heroku[web.1]: Starting process with command `npm start`
2017-06-29T02:23:44.173968+00:00 app[web.1]:
2017-06-29T02:23:44.173981+00:00 app[web.1]: > boilerplate@1.0.0 start /app
2017-06-29T02:23:44.173982+00:00 app[web.1]: > node server.js
2017-06-29T02:23:44.173983+00:00 app[web.1]:
2017-06-29T02:23:44.363574+00:00 app[web.1]: Express server is up on port 33572
2017-06-29T02:23:44.528325+00:00 heroku[web.1]: State changed from starting to up
2017-06-29T02:23:46.107998+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=be07f893-a463-4382-aca3-f54874f9f19f fwd="74.108.115.246" dyno=web.1 connect=0ms service=17ms status=404 bytes=383 protocol=http
2017-06-29T02:23:46.346724+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=234b0939-c39f-471f-ab49-f74543c9aff5 fwd="74.108.115.246" dyno=web.1 connect=0ms service=5ms status=404 bytes=383 protocol=http
2017-06-29T02:59:02.062842+00:00 heroku[web.1]: Idling
2017-06-29T02:59:02.063293+00:00 heroku[web.1]: State changed from up to down
2017-06-29T02:59:02.592723+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-06-29T02:59:02.703229+00:00 heroku[web.1]: Process exited with status 143
2017-06-29T13:41:53.000000+00:00 app[api]: Build started by user
2017-06-29T13:42:16.524993+00:00 heroku[web.1]: State changed from down to starting
2017-06-29T13:42:16.287740+00:00 app[api]: Release v6 created by user
2017-06-29T13:42:16.287740+00:00 app[api]: Deploy f285b3c0 by user
2017-06-29T13:41:53.000000+00:00 app[api]: Build succeeded
2017-06-29T13:42:19.563322+00:00 heroku[web.1]: Starting process with command `npm start`
2017-06-29T13:42:23.209966+00:00 app[web.1]:
2017-06-29T13:42:23.209986+00:00 app[web.1]: > boilerplate@1.0.0 start /app
2017-06-29T13:42:23.209987+00:00 app[web.1]: > node server.js
2017-06-29T13:42:23.209987+00:00 app[web.1]:
2017-06-29T13:42:23.634312+00:00 app[web.1]: Express server is up on port 44049
2017-06-29T13:42:24.099862+00:00 heroku[web.1]: State changed from starting to up
2017-06-29T13:43:26.907194+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=ab9bfd92-c388-4b0e-a4fb-f27a2099cf24 fwd="24.103.114.219" dyno=web.1 connect=1ms service=50ms status=302 bytes=367 protocol=https
2017-06-29T13:43:27.054007+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-hollows-69063.herokuapp.com request_id=2b112cae-f8d1-40d0-8ba7-092f5a191086 fwd="24.103.114.219" dyno=web.1 connect=1ms service=110ms status=404 bytes=383 protocol=http
包。 json文件:
{
"name": "boilerplate",
"version": "1.0.0",
"description": "Simple react app ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "redacted",
"license": "MIT ",
"dependencies": {
"axios": "^0.16.2",
"express": "^4.15.3",
"install": "^0.10.1",
"npm": "^5.0.3",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-router": "^2.0.1"
},
"devDependencies": {
"babel-core": "^6.5.1",
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"eslint": "^4.0.0",
"eslint-plugin-react": "^7.1.0",
"webpack": "^1.12.13"
},
"engines": {
"node": "6.11.0"
}
}
服务器。 js文件:
var express = require('express');
var app = express();
const PORT = process.env.PORT || 3000
app.use(function (req, res, next){
if (req.headers['x-forwarded-proto'] === 'http') {
next();
} else {
res.redirect('http://' + req.hostname + req.url);
}
});
app.use(express.static('public'));
app.listen(PORT, function () {
console.log('Express server is up on port ' + PORT);
});
你能解释一下为什么我会收到错误以及如何解决问题?
答案 0 :(得分:0)
确保在package.json中添加依赖项。 您还可以尝试通过将此参数添加到package.json来更改heroku服务器上使用的节点版本。例如:
"engines": {
"node": "8.0.0"
},
此外,你应该在你的环境中使用Heroku确定的端口
app.set('port', process.env.PORT || 8080);
//...
app.listen(app.get('port'), function (err) {
//...
})