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

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

JavaScript test spies, stubs and mocks.

Last verified Sep 9, 2026 against sinon@22.1.0.

sinon publishes both a CommonJS entry and a native ESM entry (ESM added in 12.0.0). require("sinon") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "sinon" works alongside it.

## What to do

1. Nothing to change. require("sinon") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as sinon from "sinon" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: npm install -D @types/sinon

## Facts

- Latest: 22.1.0 (Jul 20, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 22.1.0
- Native ESM since: 12.0.0
- TypeScript types: @types/sinon
- Node engines: not declared
- Weekly downloads: 10.3M
- License: BSD-3-Clause

## Runtime test results for sinon@22.1.0

Installed and executed on Sep 9, 2026 with require("sinon") from a CommonJS file and import "sinon" from an ES module.

| Runtime | require("sinon") | import "sinon" |
|---|---|---|
| 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 sinon

ES modules:

```js
import * as sinon from "sinon";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
const sinon = require("sinon");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (211 versions; the newest 60 shown).

| Versions | Format | First published |
|---|---|---|
| 12.0.0 – 22.1.0 | Dual (CommonJS + ESM) | Nov 3, 2021 |
| 8.1.1 – 11.1.2 | CommonJS | Jan 22, 2020 |

## Frequently asked

**Is sinon ESM-only?**

sinon@22.1.0 ships CommonJS and ESM builds. sinon publishes both a CommonJS entry and a native ESM entry (ESM added in 12.0.0). require("sinon") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "sinon" works alongside it.

**Can I require sinon?**

Yes. sinon ships a CommonJS entry alongside the native ESM entry. require("sinon") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.

**Does sinon work in Bun?**

Yes. import "sinon" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does sinon ship TypeScript types?**

Not bundled. Install the community types with "npm install -D @types/sinon".

## Links

- [sinon on npm](https://www.npmjs.com/package/sinon)
- [Source repository](https://github.com/sinonjs/sinon)
- [HTML version](https://canirequire.com/package/sinon/)
- [JSON version](https://canirequire.com/package/sinon.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.
