canirequire › Dual (CommonJS + ESM) › ts-api-utils
Is ts-api-utils ESM-only? Can you require() it?
Utility functions for working with TypeScript's API. Successor to the wonderful tsutils. 🛠️️
Last verified Sep 9, 2026 against ts-api-utils@2.5.0. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
ts-api-utils publishes both a CommonJS entry and a native ESM entry (ESM added in 0.0.18). require("ts-api-utils") and import "ts-api-utils" both work on every supported Node.js version and in Bun.
Does ts-api-utils@2.5.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("ts-api-utils") from a CommonJS file and import "ts-api-utils" from an ES module.
| Runtime | require("ts-api-utils") | import "ts-api-utils" |
|---|---|---|
| Node.js 18 | ✗ failsTypeError | ✗ failsTypeError |
| Node.js 20 | ✗ failsTypeError | ✗ failsTypeError |
| Node.js 22 | ✗ failsTypeError | ✗ failsTypeError |
| Node.js 24 | ✗ failsTypeError | ✗ failsTypeError |
| Node.js 26 | ✗ failsTypeError | ✗ failsTypeError |
| Bun 1.4 | ✗ failsTypeError | ✗ failsTypeError |
A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.
How to import ts-api-utils
ES modules (import)
import tsApiUtils from "ts-api-utils";CommonJS (require)
const tsApiUtils = require("ts-api-utils");Module format by version
Derived from the type, main and exports fields of every stable release on npm (50 versions; the newest 50 shown).
| Versions | Format | First published |
|---|---|---|
| 0.0.18 – 2.5.0 | Dual (CommonJS + ESM) | Feb 7, 2023 |
Frequently asked
Is ts-api-utils ESM-only?
ts-api-utils@2.5.0 ships CommonJS and ESM builds. ts-api-utils publishes both a CommonJS entry and a native ESM entry (ESM added in 0.0.18). require("ts-api-utils") and import "ts-api-utils" both work on every supported Node.js version and in Bun.
Can I require ts-api-utils?
Yes. ts-api-utils ships a CommonJS entry, so require("ts-api-utils") works on every Node.js version, alongside the native ESM entry for import.
Does ts-api-utils work in Bun?
Importing ts-api-utils failed in Bun 1.4 on Sep 9, 2026: TypeError: undefined is not an object (evaluating 'ts9.TypeFlags.Intrinsic')
Does ts-api-utils ship TypeScript types?
Yes. ts-api-utils 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
- 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
- ansi-escapes 7.3.0ESM-only
- merge-descriptors 2.0.0CommonJS
- is-plain-obj 4.1.0ESM-only
- require-directory 2.1.1CommonJS
- whatwg-mimetype 5.0.0CommonJS
- proxy-from-env 2.1.0Dual
- doctrine 3.0.0CommonJS
- is-arrayish 0.3.4CommonJS