【发布时间】:2021-06-03 16:00:53
【问题描述】:
这是我在 server.js 文件中的设置:
const express = require('express');
const app = express();
const host = '0.0.0.0';
const PORT = process.env.PORT || 5001;
app.listen(PORT, host, () => {
console.log(`RABC Server is listening on port ${PORT}!`)
});
app.use(express.static('public'))
这是我的 Procfile 中的内容:
web:nodemon server.js
这是我收到的错误:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
这是我在登录端口时得到的:
PORT的值为:undefined
在我的 package.json 脚本中,我有:
"scripts": {
"start": "node server.js",
"build": "sanity build"
}
我没有 .env 文件,我不确定我是否应该有一个,以及其中有什么。
当我运行“heroku 本地网络”并在本地托管时,一切正常。
我一生中从未部署或托管过应用程序,这是我的第一次。
【问题讨论】: