canirequire › Dual (CommonJS + ESM) › tough-cookie
Is tough-cookie ESM-only? Can you require() it?
RFC6265 Cookies and Cookie Jar for node.js
Last verified Sep 9, 2026 against tough-cookie@6.0.2. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
tough-cookie publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("tough-cookie") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=16. import "tough-cookie" works alongside it.
What to do
- Nothing to change. require("tough-cookie") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=16. import * as toughCookie from "tough-cookie" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does tough-cookie@6.0.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("tough-cookie") from a CommonJS file and import "tough-cookie" from an ES module.
| Runtime | require("tough-cookie") | import "tough-cookie" |
|---|---|---|
| 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.0 | ✓ works | ✓ works |
How to import tough-cookie
ES modules (import)
import * as toughCookie from "tough-cookie";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const toughCookie = require("tough-cookie");Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (50 versions; the newest 50 shown).
| Versions | Format | First published |
|---|---|---|
| 6.0.0 – 6.0.2 | Dual (CommonJS + ESM) | Aug 14, 2025 |
| 0.9.0 – 5.1.2 | CommonJS | Oct 21, 2011 |
Frequently asked
Is tough-cookie ESM-only?
tough-cookie@6.0.2 ships CommonJS and ESM builds. tough-cookie publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("tough-cookie") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=16. import "tough-cookie" works alongside it.
Can I require tough-cookie?
Yes. tough-cookie ships a CommonJS entry alongside the native ESM entry. require("tough-cookie") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=16.
Does tough-cookie work in Bun?
Yes. import "tough-cookie" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does tough-cookie ship TypeScript types?
Yes. tough-cookie 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
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- hosted-git-info 10.1.1CommonJS
- @vitest/runner 4.1.11ESM-only
- @rollup/rollup-linux-x64-gnu 4.63.1CommonJS
- gaxios 8.0.0Dual
- path-type 6.0.0ESM-only
- assertion-error 2.0.1ESM-only
- range-parser 1.3.0CommonJS
- @opentelemetry/instrumentation 0.222.0CommonJS