canirequire › Dual (CommonJS + ESM) › jwt-decode
Is jwt-decode ESM-only? Can you require() it?
Decode JWT tokens, mostly useful for browser applications.
Last verified Sep 9, 2026 against jwt-decode@4.0.0. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
jwt-decode publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.0). require("jwt-decode") and import "jwt-decode" both work on every supported Node.js version and in Bun.
Does jwt-decode@4.0.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("jwt-decode") from a CommonJS file and import "jwt-decode" from an ES module.
| Runtime | require("jwt-decode") | import "jwt-decode" |
|---|---|---|
| Node.js 18 | ✓ works | ✓ 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 |
How to import jwt-decode
ES modules (import)
import jwtDecode from "jwt-decode";CommonJS (require)
const jwtDecode = require("jwt-decode");Module format by version
Derived from the type, main and exports fields of every stable release on npm (21 versions; the newest 21 shown).
| Versions | Format | First published |
|---|---|---|
| 4.0.0 | Dual (CommonJS + ESM) | Oct 27, 2023 |
| 1.0.0 – 3.1.2 | CommonJS | Feb 24, 2014 |
Frequently asked
Is jwt-decode ESM-only?
jwt-decode@4.0.0 ships CommonJS and ESM builds. jwt-decode publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.0). require("jwt-decode") and import "jwt-decode" both work on every supported Node.js version and in Bun.
Can I require jwt-decode?
Yes. jwt-decode ships a CommonJS entry, so require("jwt-decode") works on every Node.js version, alongside the native ESM entry for import.
Does jwt-decode work in Bun?
Yes. import "jwt-decode" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does jwt-decode ship TypeScript types?
Yes. jwt-decode 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
- crypto-js 4.2.0CommonJS
- url 0.11.4CommonJS
- es6-promise 4.2.8CommonJS
- cssnano 9.0.4ESM-only
- lodash.get 4.4.2CommonJS
- socket.io 4.8.3Dual
- assert 2.1.0CommonJS
- moment-timezone 0.6.3CommonJS