canirequire

canirequireDual (CommonJS + ESM) › svelte

Is svelte ESM-only? Can you require() it?

Cybernetically enhanced web apps

Last verified Sep 9, 2026 against svelte@5.57.0. JSON

Dual (CommonJS + ESM) Dual package — both require() and import work

svelte publishes both a CommonJS entry and a native ESM entry (ESM added in 3.29.5). require("svelte") and import "svelte" both work on every supported Node.js version and in Bun.

Latest
5.57.0 (Aug 28, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.57.0
Native ESM since
3.29.5
TypeScript types
Bundled
Node engines
>=18
Weekly downloads
4.1M
License
MIT

Does svelte@5.57.0 actually load? Runtime test results

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

Runtimerequire("svelte")import "svelte"
Node.js 18✗ failsERR_REQUIRE_ESM✓ works
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

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 svelte

ES modules (import)

import svelte from "svelte";

CommonJS (require)

const svelte = require("svelte");

Module format by version

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

VersionsFormatFirst published
5.47.1 – 5.57.0Dual (CommonJS + ESM)Jan 19, 2026

Frequently asked

Is svelte ESM-only?

svelte@5.57.0 ships CommonJS and ESM builds. svelte publishes both a CommonJS entry and a native ESM entry (ESM added in 3.29.5). require("svelte") and import "svelte" both work on every supported Node.js version and in Bun.

Can I require svelte?

Yes. svelte ships a CommonJS entry, so require("svelte") works on every Node.js version, alongside the native ESM entry for import.

Does svelte work in Bun?

Yes. import "svelte" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does svelte ship TypeScript types?

Yes. svelte bundles its own type declarations; no @types package is needed.

Links

Other dual (commonjs + esm) packages

Similar popularity