canirequire

canirequire › ESM-only › @rollup/plugin-alias

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

Define and resolve aliases for bundle dependencies

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

ESM-only ESM-only since 6.0.0 — last CommonJS version is 5.1.1

@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.
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

Does @rollup/plugin-alias@6.0.0 actually load? Runtime test results

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.

Runtimerequire("@rollup/plugin-alias")import "@rollup/plugin-alias"
Node.js 18✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 20✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 22✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 24✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 26✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Bun 1.4.0✗ failsError✓ works

How to import @rollup/plugin-alias

ES modules (import)

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 (require)

// 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, corrected where a runtime test of that version contradicted them (23 versions; the newest 23 shown).

VersionsFormatFirst published
6.0.0ESM-onlyOct 28, 2025
4.0.0 – 5.1.1Dual (CommonJS + ESM)Oct 7, 2022
2.2.0 – 3.1.9CommonJSOct 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

Other esm-only packages

Similar popularity