canirequire

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

Dual (CommonJS + ESM) Dual package — both require() and import work

sinon publishes both a CommonJS entry and a native ESM entry (ESM added in 12.0.0). require("sinon") and import "sinon" both work on every supported Node.js version and in Bun.

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

How to import sinon

ES modules (import)

import sinon from "sinon";

CommonJS (require)

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

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") and import "sinon" both work on every supported Node.js version and in Bun.

Can I require sinon?

Yes. sinon ships a CommonJS entry, so require("sinon") works on every Node.js version, alongside the native ESM entry for import.

Does sinon work in Bun?

Yes. import "sinon" loaded successfully in Bun 1.4 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