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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
tough-cookie publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("tough-cookie") and import "tough-cookie" both work on every supported Node.js version and in Bun.
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 | ✓ works | ✓ works |
How to import tough-cookie
ES modules (import)
import toughCookie from "tough-cookie";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 (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") and import "tough-cookie" both work on every supported Node.js version and in Bun.
Can I require tough-cookie?
Yes. tough-cookie ships a CommonJS entry, so require("tough-cookie") works on every Node.js version, alongside the native ESM entry for import.
Does tough-cookie work in Bun?
Yes. import "tough-cookie" loaded successfully in Bun 1.4 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
- 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
- get-tsconfig 4.14.3Dual
- hosted-git-info 10.1.1CommonJS
- @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
- d3-array 3.2.4ESM-only