https://i.sstatic.net/B4bqV.pnghttps://i.sstatic.net/QfJqv.pngMy current code utilizes socket.io to display a message. However, when I execute node server.js, none of the output messages are being logged to the console. Below are snippets of my chat.html, server.js, and main.js files that contain the socket.io code.
chat.html
<script src="http://localhost:54159/socket.io/socket.io.js"></script>
<script src="js/main.js"></script>
server.js
const http = require('http');
const express = require('express');
const socketio = require('socket.io');
const app = express();
const server = http.createServer(app);
const io = socketio(server);
app.use(express.static(path.join(__dirname, 'public')));
io.on('connection', (socket) => {
console.log('New web socket connection...');
socket.emit('message', 'Welcome to Chat Room!');
});
const PORT = 54159 || process.env.PORT;
server.listen(PORT, () => console.log(`Server running on port ${PORT}`));
main.js
const socket = io();