У меня установлены express
и socket-io
серверы
Я не знаю, с чего начать, чтобы решить эту ошибку
Любая помощь?
events.js:173
throw er; // Unhandled 'error' event
[0] ^
[0]
[0] Error: listen EADDRINUSE: address already in use :::5000
[0] at Server.setupListenHandle [as _listen2] (net.js:1226:14)
[0] at listenInCluster (net.js:1274:12)
[0] at Server.listen (net.js:1362:7)
at Object.<anonymous> (C:\Users\ahmed\Desktop\HTML CSS JS REACT\000. Personal\books-overflow\server.js:68:8)
[0] at Module._compile (internal/modules/cjs/loader.js:759:30)
[0] at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
[0] at Module.load (internal/modules/cjs/loader.js:628:32)
[0] at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:824:10)
[0] at internal/main/run_main_module.js:17:11
[0] Emitted 'error' event at:
[0] at emitErrorNT (net.js:1253:8)
[0] at processTicksAndRejections (internal/process/task_queues.js:84:17)
[0] [nodemon] app crashed - waiting for file changes before starting...
Вот мой server.js
const express = require('express');
const cors = require('cors');
const path = require('path');
const http = require('http');
const socketio = require('socket.io');
const compression = require('compression');
const enforce = require('express-sslify');
if (process.env.NODE_ENV !== 'production') require('dotenv').config();
const app = express();
const server = http.createServer(app);
const io = socketio(server);
const connectMongoDB = require('./database/mongo-db');
connectMongoDB();
// Init Middleware
app.use(compression());
app.use(express.json({ extended: false }));
app.use(cors());
// Define Routers
app.use('/api/users', require('./routes/users/profile'));
// contains all event handlers
require('./socket-io/main')(io);
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
app.use(enforce.HTTPS({ trustProtoHeader: true }));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
app.get('/service-worker.js', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'build', 'service-worker.js'));
});
server.listen(process.env.PORT, () =>
console.log(`Server started on port ${process.env.PORT}`)
);
Я пытался изменить порт на 8000, но та же ошибка.очевидно, они запускаются одновременно в коде
$ netstat -ano | findstr :5000
TCP 0.0.0.0:5000 0.0.0.0:0 LISTENING 44812
TCP [::]:5000 [::]:0 LISTENING 44812