# Is @rollup/plugin-alias ESM-only? Can you require() it?

> @rollup/plugin-alias@6.0.0 is ESM-only. ESM-only since 6.0.0 — last CommonJS version is 5.1.1.

Define and resolve aliases for bundle dependencies

Last verified Sep 9, 2026 against @rollup/plugin-alias@6.0.0.

@rollup/plugin-alias dropped its CommonJS build in 6.0.0 (October 2025). The last version with a plain require()-able CommonJS entry is 5.1.1, published Sep 22, 2024; it declares support for Node.js >=14.0.0.

require("@rollup/plugin-alias") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Node.js 18 has no require(esm), and @rollup/plugin-alias@6.0.0 declares Node.js >=20.19.0, so 18 is outside its supported range anyway.

@rollup/plugin-alias@6.0.0 declares engines ">=20.19.0", so Node.js 18 is outside its supported range regardless of module format.

## What to do

1. require("@rollup/plugin-alias") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
2. From a CommonJS file, use a dynamic import inside an async function: const pluginAlias = await import("@rollup/plugin-alias"). That works on every Node.js version the package supports (>=20.19.0).
3. If you need a synchronous require() or run Node.js 18: npm install @rollup/plugin-alias@5.1.1, the last CommonJS release (published Sep 22, 2024); it declares Node.js >=14.0.0.
4. @rollup/plugin-alias@6.0.0 declares engines ">=20.19.0", so Node.js 18 is unsupported regardless: upgrade Node.js or pin an older release.
5. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 6.0.0 (Oct 28, 2025)
- Module format: ESM-only
- Last CommonJS version: 5.1.1
- ESM-only since: 6.0.0 (Oct 28, 2025)
- TypeScript types: bundled
- Node engines: >=20.19.0
- Weekly downloads: 3.8M
- License: MIT

## Runtime test results for @rollup/plugin-alias@6.0.0

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

| Runtime | require("@rollup/plugin-alias") | import "@rollup/plugin-alias" |
|---|---|---|
| Node.js 18 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | works |
| Node.js 20 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | works |
| Node.js 22 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | works |
| Node.js 24 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | works |
| Node.js 26 | fails (ERR_PACKAGE_PATH_NOT_EXPORTED) | works |
| Bun 1.4.0 | fails (Error) | works |

## How to import @rollup/plugin-alias

ES modules:

```js
import * as pluginAlias from "@rollup/plugin-alias";
```

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

CommonJS:

```js
// require("@rollup/plugin-alias") failed in our probe on Node.js 20.19+, 22.12+ and newer as well (ERR_PACKAGE_PATH_NOT_EXPORTED); see the runtime table.

// Any Node.js version the package supports (>=20.19.0), from an async function:
async function main() {
  const pluginAlias = await import("@rollup/plugin-alias");
}

// Or pin the last CommonJS release (declares Node.js >=14.0.0):
// npm install @rollup/plugin-alias@5.1.1
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 6.0.0 | ESM-only | Oct 28, 2025 |
| 4.0.0 – 5.1.1 | Dual (CommonJS + ESM) | Oct 7, 2022 |
| 2.2.0 – 3.1.9 | CommonJS | Oct 30, 2019 |

## Frequently asked

**Is @rollup/plugin-alias ESM-only?**

@rollup/plugin-alias@6.0.0 is ESM-only. @rollup/plugin-alias dropped its CommonJS build in 6.0.0 (October 2025). The last version with a plain require()-able CommonJS entry is 5.1.1, published Sep 22, 2024; it declares support for Node.js >=14.0.0.

**Which version of @rollup/plugin-alias still supports CommonJS / require()?**

5.1.1 is the last version of @rollup/plugin-alias with a CommonJS build; it declares Node.js >=14.0.0. Install it with "npm install @rollup/plugin-alias@5.1.1". Every version from 6.0.0 on is ESM-only.

**How do I use @rollup/plugin-alias from a CommonJS file?**

From a CommonJS file, use a dynamic import inside an async function: const pluginAlias = await import("@rollup/plugin-alias"). That works on every Node.js version the package supports (>=20.19.0). require("@rollup/plugin-alias") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Alternatively pin @rollup/plugin-alias@5.1.1 (declares Node.js >=14.0.0).

**Does @rollup/plugin-alias work in Bun?**

Yes. import "@rollup/plugin-alias" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does @rollup/plugin-alias ship TypeScript types?**

Yes. @rollup/plugin-alias bundles its own type declarations; no @types package is needed.

## Links

- [@rollup/plugin-alias on npm](https://www.npmjs.com/package/@rollup/plugin-alias)
- [Source repository](https://github.com/rollup/plugins)
- [HTML version](https://canirequire.com/package/@rollup/plugin-alias/)
- [JSON version](https://canirequire.com/package/@rollup/plugin-alias.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.
