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

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

A tiny invariant function

Last verified Sep 9, 2026 against tiny-invariant@1.3.3.

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

## What to do

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

## Facts

- Latest: 1.3.3 (Feb 23, 2024)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 1.3.3
- Native ESM since: 1.3.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 72.9M
- License: MIT

## Runtime test results for tiny-invariant@1.3.3

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

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

ES modules:

```js
import * as tinyInvariant from "tiny-invariant";
```

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

CommonJS:

```js
const tinyInvariant = require("tiny-invariant");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 1.3.0 – 1.3.3 | Dual (CommonJS + ESM) | Sep 28, 2022 |
| 0.0.1 – 1.2.0 | CommonJS | Apr 17, 2018 |

## Frequently asked

**Is tiny-invariant ESM-only?**

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

**Can I require tiny-invariant?**

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

**Does tiny-invariant work in Bun?**

Yes. import "tiny-invariant" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does tiny-invariant ship TypeScript types?**

Yes. tiny-invariant bundles its own type declarations; no @types package is needed.

## Links

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