Not sure why I am getting the error. When I try to do the same thing by using request it works fine.
import express from 'express';
import { createServer } from 'http';
import * as io from 'socket.io';
const app = express();
const server = createServer(app);
const socketio = io(server);
Error
const socketio = io(server);
^
TypeError: io is not a function
You should try this instead
import { Server } from "socket.io";
const httpServer = createServer();
const io = new Server(httpServer, {
// ...
});
Check it out here Socket.io Initialization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With