canirequire

canirequireDual (CommonJS + ESM) › vue-router

Is vue-router ESM-only? Can you require() it?

Last verified Sep 9, 2026 against vue-router@5.3.1. JSON

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

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

Latest
5.3.1 (Sep 2, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.3.1
Native ESM since
3.6.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
5.8M
License
MIT

Does vue-router@5.3.1 actually load? Runtime test results

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

Runtimerequire("vue-router")import "vue-router"
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 vue-router

ES modules (import)

import vueRouter from "vue-router";

CommonJS (require)

const vueRouter = require("vue-router");

Module format by version

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

VersionsFormatFirst published
4.1.0 – 5.3.1Dual (CommonJS + ESM)Jul 4, 2022
4.0.0 – 4.0.16CommonJSDec 7, 2020
3.6.5Dual (CommonJS + ESM)Sep 6, 2022

Frequently asked

Is vue-router ESM-only?

vue-router@5.3.1 ships CommonJS and ESM builds. vue-router publishes both a CommonJS entry and a native ESM entry (ESM added in 3.6.0). require("vue-router") and import "vue-router" both work on every supported Node.js version and in Bun.

Can I require vue-router?

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

Does vue-router work in Bun?

Yes. import "vue-router" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does vue-router ship TypeScript types?

Yes. vue-router bundles its own type declarations; no @types package is needed.

Links

Other dual (commonjs + esm) packages

Similar popularity