嗨,我刚刚跟踪了Udemy类中的代码,但是打开Heroku时遇到了问题。 我是这里的新手,希望有人能帮助我
Index.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send({ hi: 'there' });
});
const PORT = process.env.PORT || 5000;
app.listen(5000);
Package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "12.16.2",
"npm": "6.14.4"
},
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
错误
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
at=error code=H10 desc="App crashed" method=GET path="/" host=radiant-cliffs-96699.herokuapp.com request_id=ea43a5f3-75e7-4815-a059-a62d486c79f4 fwd="69.157.0.58" dyno= connect= service= status=503 bytes= protocol=https
答案 0 :(得分:0)
const PORT = process.env.PORT || 5000;
app.listen(5000);
您没有在听变量PORT
。您一直在听5000
。绑定到PORT
。