mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-13 17:07:54 -05:00
Both CommonJS and ES6 import are now supported:
- with `{ "type": "commonjs" }` in the package.json file
```js
const io = require("socket.io")(8080);
// or
const { Server } = require("socket.io");
const io = new Server(8080);
```
- with `{ "type": "module" }`
```js
import { Server } from "socket.io";
const io = new Server(8080);
```
Related: https://nodejs.org/api/packages.html#packages_dual_commonjs_es_module_packages
4 lines
68 B
JavaScript
4 lines
68 B
JavaScript
import io from "./dist/index.js";
|
|
|
|
export const Server = io.Server;
|