canirequire › Dual (CommonJS + ESM) › @sinclair/typebox
Is @sinclair/typebox ESM-only? Can you require() it?
Json Schema Type Builder with Static Type Resolution for TypeScript
Last verified Sep 9, 2026 against @sinclair/typebox@0.34.52. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
@sinclair/typebox publishes both a CommonJS entry and a native ESM entry (ESM added in 0.32.0). require("@sinclair/typebox") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@sinclair/typebox" works alongside it.
What to do
- Nothing to change. require("@sinclair/typebox") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as typebox from "@sinclair/typebox" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does @sinclair/typebox@0.34.52 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@sinclair/typebox") from a CommonJS file and import "@sinclair/typebox" from an ES module.
| Runtime | require("@sinclair/typebox") | import "@sinclair/typebox" |
|---|---|---|
| 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 @sinclair/typebox
ES modules (import)
import * as typebox from "@sinclair/typebox";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const typebox = require("@sinclair/typebox");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 (363 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 0.33.18 – 0.34.52 | Dual (CommonJS + ESM) | Nov 6, 2024 |
Frequently asked
Is @sinclair/typebox ESM-only?
@sinclair/typebox@0.34.52 ships CommonJS and ESM builds. @sinclair/typebox publishes both a CommonJS entry and a native ESM entry (ESM added in 0.32.0). require("@sinclair/typebox") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "@sinclair/typebox" works alongside it.
Can I require @sinclair/typebox?
Yes. @sinclair/typebox ships a CommonJS entry alongside the native ESM entry. require("@sinclair/typebox") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
Does @sinclair/typebox work in Bun?
Yes. import "@sinclair/typebox" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does @sinclair/typebox ship TypeScript types?
Yes. @sinclair/typebox bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- @radix-ui/react-use-controllable-state 1.2.6Dual
- ip-address 10.7.0CommonJS
- @aws-sdk/token-providers 3.1128.0CommonJS
- binary-extensions 3.2.0ESM-only
- is-generator-function 1.1.2CommonJS
- @eslint/config-array 0.23.5Dual
- @aws-sdk/core 3.977.9Dual
- regexp.prototype.flags 1.5.4CommonJS