canirequire › Dual (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.
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.
| Runtime | require("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).
| Versions | Format | First published |
|---|---|---|
| 4.1.0 – 5.3.1 | Dual (CommonJS + ESM) | Jul 4, 2022 |
| 4.0.0 – 4.0.16 | CommonJS | Dec 7, 2020 |
| 3.6.5 | Dual (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
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- mongoose 9.9.5CommonJS
- ncp 2.0.0CommonJS
- electron 44.3.0CommonJS
- tsup 8.5.1No entry
- lit-element 4.2.2ESM-only
- eslint-plugin-jsdoc 64.3.8ESM-only
- bootstrap 5.3.8CommonJS
- event-stream 4.0.1CommonJS