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. 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.
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.
| 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 | ✓ 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).
| 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") 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
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- mongodb 7.6.0CommonJS
- puppeteer 25.10.0Dual
- @nestjs/common 12.0.1ESM-only
- cookie-parser 1.4.7CommonJS
- history 5.3.0CommonJS
- webpack-cli 7.2.3CommonJS
- eslint-plugin-jest 29.16.6CommonJS
- isomorphic-fetch 3.0.0CommonJS