canirequire

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

  1. 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.
  2. TypeScript: types are bundled; install nothing extra.
Latest
6.0.2 (Jul 7, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
6.0.2
Native ESM since
6.0.0
TypeScript types
Bundled
Node engines
>=16
Weekly downloads
90.5M
License
BSD-3-Clause

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.

Runtimerequire("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).

VersionsFormatFirst published
6.0.0 – 6.0.2Dual (CommonJS + ESM)Aug 14, 2025
0.9.0 – 5.1.2CommonJSOct 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

Similar popularity