canirequire

canirequire › Dual (CommonJS + ESM) › sinon

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

JavaScript test spies, stubs and mocks.

Last verified Sep 9, 2026 against sinon@22.1.0. Markdown · JSON

Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too

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

Does sinon@22.1.0 actually load? Runtime test results

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

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

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 (require)

const sinon = require("sinon");

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 (211 versions; the newest 60 shown).

VersionsFormatFirst published
12.0.0 – 22.1.0Dual (CommonJS + ESM)Nov 3, 2021
8.1.1 – 11.1.2CommonJSJan 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

Other dual (commonjs + esm) packages

Similar popularity