canirequire

canirequireDual (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.

Latest
4.0.0 (Oct 27, 2023)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
4.0.0
Native ESM since
4.0.0
TypeScript types
Bundled
Node engines
>=18
Weekly downloads
16.3M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
4.0.0Dual (CommonJS + ESM)Oct 27, 2023
1.0.0 – 3.1.2CommonJSFeb 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

Similar popularity