How do we use socket.io library with ecmascript module syntax? I'm getting following error if I'm importing it like this:
import socketIO from "socket.io";
Error:
SyntaxError: The requested module 'socket.io' does not provide an export named 'default'
CodePudding user response:
Try:
import {Socket} from ‘socket.io’
The socket.io package exports a server module as well so a default export won’t work here.
You can also do:
import * as SocketIO from ‘socket.io’
Then you will need to do socketIO.Socket