Angel Choque
Con module
import express from "express"; import { createServer } from 'http'; import path from "path"; import { Server } from "socket.io"; import * as url from 'url'; const app = express(); const httpServer = createServer(app); const io = new Server(httpServer); const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); app.use(express.static(path.join(__dirname, '/views'))); app.get('/', (req, res) => { res.sendFile(__dirname + '/views/index.html'); }); io.on('connection', (socket) => { console.log(socket.id); }); httpServer.listen(3000);