What's Changed
@nestjs/jwt is now a native ES module, and the major version is aligned with the Nest 12 release line
ESM migration
The package is published as pure ESM ("type": "module", compiled with NodeNext) behind a proper exports map. The legacy root index.js / index.d.ts / index.ts shims are gone, and deep imports into build internals are no longer resolvable — import from the package root.
// ✅
import { JwtModule, JwtService } from '@nestjs/jwt';
// ❌ no longer resolvable
import { JwtService } from '@nestjs/jwt/dist/jwt.service';require(esm) — CommonJS still works
You do not need to convert your app to ESM. Thanks to Node's require(esm) support (Node 20.19+, 22.12+, and all of 24.x), a CommonJS Nest application can keep requiring the package exactly as before:
const { JwtModule, JwtService } = require('@nestjs/jwt');TypeScript users compiling to CommonJS are unaffected as long as their runtime is on a supported Node version. On older Node releases, require() of this package will throw ERR_REQUIRE_ESM — upgrade Node, or switch the consuming code to import.
jsonwebtoken re-exports
The error classes re-exported from jsonwebtoken (TokenExpiredError, NotBeforeError, JsonWebTokenError) are now re-exported explicitly by name instead of via a star export, so they resolve correctly under ESM interop with the CJS jsonwebtoken package. No import changes are needed on your side:
import { TokenExpiredError } from '@nestjs/jwt';Upgrading
npm install @nestjs/jwt@12For most applications this is a drop-in upgrade. Action is only required if you were relying on deep imports into dist/, or are running a Node version older than 20.19 with a CommonJS app.