question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The requested module 'socket.io' does not provide an export named 'default' after upgrade to 3.0

See original GitHub issue

Note: for support questions, please use one of these channels: stackoverflow or slack

For bug reports and feature requests for the Swift client, please open an issue there.

For bug reports and feature requests for the Java client, please open an issue there.

You want to:

  • report a bug
  • request a feature

Current behaviour

What is actually happening?

import SocketIO from "socket.io";
export const io = SocketIO(server, {
    pingInterval: 10000,
    pingTimeout: 5000,
});

Then i get an error in console:

import SocketIO from "socket.io";
       ^^^^^^^^
SyntaxError: The requested module 'socket.io' does not provide an export named 'default'

Steps to reproduce (if the current behaviour is a bug)

  1. Install socket.io 3.0 and node 15.0.1
  2. Enable type: “module” and --es-module-specifier-resolution=node
  3. Get error

Note: the best way (and by that we mean the only way) to get a quick answer is to provide a failing test case by forking the following fiddle.

Expected behaviour

Importing and running like before

What is expected?

Setup

  • OS: Mac os Catalina
  • browser: no browser
  • socket.io version: 3.0

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
darrachequesnecommented, Nov 8, 2020

You’re right, this part was missing from the migration guide, sorry for that.

Server:

import { Server } from "socket.io";

const io = new Server(httpServer);

Client:

import io from "socket.io-client";

const socket = io();

// or, more explicit version
import { Manager } from "socket.io-client";

const manager = new Manager("https://example.com");
const socket = manager.socket("/");
8reactions
Sjonnie2ndcommented, Nov 6, 2020

I got it working with

import {Server, Socket} from 'socket.io'; const io = new Server(server);

But after it: be aware to update the client-side to 3.0.0 too! https://github.com/socketio/socket.io-client

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import socket.io npm packege - Nodejs - Stack Overflow
There are two kinds of exports: named exports (several per module) and default exports (one per module). It is possible to use both...
Read more >
Migrating from 2.x to 3.0 - Socket.IO
A v3 client is still not be able to connect to a v2 server though. ... to the default namespace ( / ),...
Read more >
Requested module does not provide export named 'default'
To solve the error "The requested module does not provide an export named 'default' ...
Read more >
socket.io-client - npm
Start using socket.io-client in your project by running `npm i socket.io-client`. There are 7127 other projects in the npm registry using ...
Read more >
the requested module 'vue' does not provide an export named ...
The thing you want to do is import vue but it doesnot have a default export function or either the default thing to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found