-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't import/require Socket class. returns 'undefined' #3726
Comments
I'm facing the same problem with the client library. |
Hi! I could indeed reproduce. Out of curiosity, why do you need a direct reference to the Socket class? |
For extending the socket class methods :) |
darrachequesne
added a commit
to socketio/socket.io-client
that referenced
this issue
May 6, 2021
Before this change, `require("socket.io-client").Socket` would return "undefined". Note: having access to the Socket class allows users to modify its prototype. Related: socketio/socket.io#3726
darrachequesne
added a commit
that referenced
this issue
May 6, 2021
Before this change, `require("socket.io").Socket` would return "undefined". Note: having access to the Socket class allows users to modify its prototype. Related: #3726
This should be fixed by d65b6ee, included in Thanks for the report 👍 |
sunrise30
added a commit
to sunrise30/socket.io-client
that referenced
this issue
Jan 8, 2022
Before this change, `require("socket.io-client").Socket` would return "undefined". Note: having access to the Socket class allows users to modify its prototype. Related: socketio/socket.io#3726
dzad
pushed a commit
to dzad/socket.io
that referenced
this issue
May 29, 2023
Before this change, `require("socket.io").Socket` would return "undefined". Note: having access to the Socket class allows users to modify its prototype. Related: socketio#3726
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version 3:
const {Socket} = require('socket.io') //according to index.d.ts declaration
console.log(Socket) //=>undefined!
Version 2 (for reference):
const Socket = require('socket.io/lib/socket') //ok. /lib/socket no longer exists in version 3
The text was updated successfully, but these errors were encountered: