canirequire

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

Latest
2.5.0 (Mar 19, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
2.5.0
Native ESM since
0.0.18
TypeScript types
Bundled
Node engines
>=18.12
Weekly downloads
112.7M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
0.0.18 – 2.5.0Dual (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

Similar popularity