# Is tough-cookie ESM-only? Can you require() it?

> tough-cookie@6.0.2 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

RFC6265 Cookies and Cookie Jar for node.js

Last verified Sep 9, 2026 against tough-cookie@6.0.2.

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.

## Facts

- 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

## Runtime test results for tough-cookie@6.0.2

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:

```js
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:

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

- [tough-cookie on npm](https://www.npmjs.com/package/tough-cookie)
- [Source repository](https://github.com/salesforce/tough-cookie)
- [HTML version](https://canirequire.com/package/tough-cookie/)
- [JSON version](https://canirequire.com/package/tough-cookie.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
