Skip to content
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

4.3.0 broken #1505

Closed
saknarak opened this issue Oct 15, 2021 · 3 comments
Closed

4.3.0 broken #1505

saknarak opened this issue Oct 15, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@saknarak
Copy link

saknarak commented Oct 15, 2021

4.3.0 is broken
io is not a function

To Reproduce

npm init -y
npm install socket.io-client
node index
```js
// index.js
const io = require('socket.io-client')
const socket = io('http://localhost:7000', {})

error output

const socket = io('http://localhost:7000')
               ^

TypeError: io is not a function
    at Object.<anonymous> (D:\work\sak\test-socket\index.js:2:16)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

Package version

  "dependencies": {
    "socket.io-client": "^4.3.0"
  }

Expected behavior
io should be a function

@saknarak saknarak added the bug Something isn't working label Oct 15, 2021
@darrachequesne
Copy link
Member

Hi! The following should work:

const { io } = require('socket.io-client')
const socket = io('http://localhost:7000', {})

That is a breaking change though, I'm digging into this 👀

@saknarak
Copy link
Author

Thank you!

darrachequesne added a commit that referenced this issue Oct 15, 2021
The default export was accidentally removed in [1].

Note: that being said, users are encouraged to use the named exports,
because the default export has a different meaning for CommonJS and ES
modules users.

```js
// BAD
import io from "socket.io-client";

// GOOD
import { io } from "socket.io-client";
```

Related:

- #1505
- #1507
- #1508

[1]: 16b6569
@darrachequesne
Copy link
Member

This should be fixed in version 4.3.1, sorry for this.

sunrise30 added a commit to sunrise30/socket.io-client that referenced this issue Jan 8, 2022
The default export was accidentally removed in [1].

Note: that being said, users are encouraged to use the named exports,
because the default export has a different meaning for CommonJS and ES
modules users.

```js
// BAD
import io from "socket.io-client";

// GOOD
import { io } from "socket.io-client";
```

Related:

- socketio/socket.io-client#1505
- socketio/socket.io-client#1507
- socketio/socket.io-client#1508

[1]: socketio/socket.io-client@16b6569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants