well it was my mistake only i was initializing the server with socket.io twice which was causing the issue
I resolved the same problem when I ran
npm install socket.io
Basically, I forgot to install socket to the project.
Use the same version of
socket.io-client on both server and client.