canirequire

canirequireDual (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.

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✓ 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).

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") 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

Similar popularity