# Is vite-plugin-dts ESM-only? Can you require() it?

> vite-plugin-dts@5.1.0 declares CommonJS and ESM builds, but require() fails at runtime. Dual package on paper — require() failed in our runtime test.

<h1 align="center">vite-plugin-dts</h1>

Last verified Sep 9, 2026 against vite-plugin-dts@5.1.0.

vite-plugin-dts declares both a CommonJS entry and a native ESM entry (ESM added in 1.6.2), but require("vite-plugin-dts") failed on every Node.js version in our probe: [unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the…. That usually means a missing peer dependency, a browser-only global, or a package that refuses to be loaded with require(); see the runtime table below.

## What to do

1. require("vite-plugin-dts") failed in our probe on every Node.js version ([unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the…); check the package README for peer dependencies or setup before relying on it.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 5.1.0 (Sep 1, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 5.1.0
- Native ESM since: 1.6.2
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 3.5M
- License: MIT

## Runtime test results for vite-plugin-dts@5.1.0

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

| Runtime | require("vite-plugin-dts") | import "vite-plugin-dts" |
|---|---|---|
| Node.js 18 | fails (Error) | fails (Error) |
| Node.js 20 | fails (Error) | fails (Error) |
| Node.js 22 | fails (Error) | fails (Error) |
| Node.js 24 | fails (Error) | fails (Error) |
| Node.js 26 | fails (Error) | fails (Error) |
| Bun 1.4.0 | fails (Error) | fails (Error) |

## How to import vite-plugin-dts

ES modules:

```js
import * as vitePluginDts from "vite-plugin-dts";
```

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

CommonJS:

```js
// require("vite-plugin-dts") failed in our probe on every Node.js version we test ([unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the…); see the runtime table.
const vitePluginDts = require("vite-plugin-dts");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 1.7.2 – 5.1.0 | Dual (CommonJS + ESM) | Jan 31, 2023 |

## Frequently asked

**Is vite-plugin-dts ESM-only?**

vite-plugin-dts@5.1.0 declares CommonJS and ESM builds, but require() fails at runtime. vite-plugin-dts declares both a CommonJS entry and a native ESM entry (ESM added in 1.6.2), but require("vite-plugin-dts") failed on every Node.js version in our probe: [unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the…. That usually means a missing peer dependency, a browser-only global, or a package that refuses to be loaded with require(); see the runtime table below.

**Can I require vite-plugin-dts?**

Not in practice. vite-plugin-dts declares a CommonJS entry, but require("vite-plugin-dts") failed on every Node.js version in our probe: [unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the…. Check the package README for peer dependencies or setup before relying on it.

**Does vite-plugin-dts work in Bun?**

Importing vite-plugin-dts failed in Bun 1.4.0 on Sep 9, 2026: error: [unplugin-dts] The installed "typescript" package does not provide the JavaScript Compiler API (this happens with TypeScript 7+), and the fallback "@typescript/typescript6" was not found.

**Does vite-plugin-dts ship TypeScript types?**

Yes. vite-plugin-dts bundles its own type declarations; no @types package is needed.

## Links

- [vite-plugin-dts on npm](https://www.npmjs.com/package/vite-plugin-dts)
- [Source repository](https://github.com/qmhc/unplugin-dts)
- [HTML version](https://canirequire.com/package/vite-plugin-dts/)
- [JSON version](https://canirequire.com/package/vite-plugin-dts.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.
