canirequire › Dual (CommonJS + ESM) › socket.io-client
Is socket.io-client ESM-only? Can you require() it?
Realtime application framework client
Last verified Sep 9, 2026 against socket.io-client@4.8.3. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
socket.io-client publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("socket.io-client") and import "socket.io-client" both work on every supported Node.js version and in Bun.
Does socket.io-client@4.8.3 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("socket.io-client") from a CommonJS file and import "socket.io-client" from an ES module.
| Runtime | require("socket.io-client") | import "socket.io-client" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
How to import socket.io-client
ES modules (import)
import socketIoClient from "socket.io-client";CommonJS (require)
const socketIoClient = require("socket.io-client");Module format by version
Derived from the type, main and exports fields of every stable release on npm (119 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 4.8.3 | Dual (CommonJS + ESM) | Nov 5, 2020 |
| 1.5.1 – 2.5.0 | CommonJS | Oct 24, 2016 |
Frequently asked
Is socket.io-client ESM-only?
socket.io-client@4.8.3 ships CommonJS and ESM builds. socket.io-client publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("socket.io-client") and import "socket.io-client" both work on every supported Node.js version and in Bun.
Can I require socket.io-client?
Yes. socket.io-client ships a CommonJS entry, so require("socket.io-client") works on every Node.js version, alongside the native ESM entry for import.
Does socket.io-client work in Bun?
Yes. import "socket.io-client" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does socket.io-client ship TypeScript types?
Yes. socket.io-client bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- html-webpack-plugin 5.6.8CommonJS
- querystring 0.2.1CommonJS
- postcss-loader 8.2.1CommonJS
- resize-observer-polyfill 1.5.1CommonJS
- portfinder 1.0.38CommonJS
- request 2.88.2CommonJS
- postcss-calc 11.1.1ESM-only
- nodemon 3.1.14CommonJS