gpt4 book ai didi

javascript - Heroku:端口上已经有东西在运行

转载 作者:行者123 更新时间:2023-12-03 01:37:11 25 4
gpt4 key购买 nike

我是 Heroku 新手,我正在尝试部署我的节点服务器和 create-react-app 前端应用程序。一切都在本地运行得很好,但是当我尝试在 Heroku 上运行它时,一切都崩溃了。我没有收到任何部署错误,并且在我的 URL 处仅看到 Cannot GET/

我的日志说:

Something is already running on port 12345

/server/app.js

var express = require('express');
var app = express();
require('dotenv').config();
var mongoose = require('mongoose');
var config = require('./config');
var apiController = require('./controllers/apiController');

var port = process.env.PORT || 3005;

app.use('/', express.static(__dirname + '/public'));

app.set('view engine', 'ejs');

mongoose.connect(config.getDbConnectionString());
apiController(app);

app.listen(port);

package.json

{
"name": "happy-holidays",
"version": "1.0.0",
"description": "",
"engines": {
"node": "8.9.4"
},
"scripts": {
"start": "concurrently --kill-others-on-fail \"yarn run server\" \"yarn run client\"",
"server": "cd server && yarn start",
"client": "cd react-ui && yarn start"
},
"license": "UNLICENSED" ,
"cacheDirectories": [
"node_modules",
"react-ui/node_modules"
],
"dependencies": {
"@sendgrid/mail": "^6.2.1",
"axios": "^0.18.0",
"body-parser": "^1.18.2",
"bootstrap": "^4.1.1",
"concurrently": "^3.5.1",
"dotenv": "^5.0.1",
"ejs": "^2.6.1",
"express": "^4.16.3",
"mongoose": "^5.1.0",
"react": "^16.3.2",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.3.2",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"semantic-ui-css": "^2.3.1",
"semantic-ui-react": "^0.80.2"
},
"repository": {
"type": "git",
"url": "https://github.com/SaraRandolph/messagez"
},
"devDependencies": {}
}

最佳答案

“为什么端口 12345 来了而不是 3005 ?”

因为 HEROKU 动态分配 PORT。

关于javascript - Heroku:端口上已经有东西在运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51013870/

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