What's Changed
@nestjs/mongoose 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. Deep imports into build internals (@nestjs/mongoose/dist/...) are no longer resolvable — import from the package root:
import { InjectModel, MongooseModule, Prop, Schema, SchemaFactory } from '@nestjs/mongoose';require(esm) — CommonJS still works
You do not need to convert your app to ESM. Thanks to Node's require(esm) support, the package resolves through the default export condition and can be loaded from CommonJS as-is:
const { MongooseModule } = require('@nestjs/mongoose');This requires Node.js 20.19+ or 22.12+ (where require(esm) is enabled by default). On older Node versions you'll need to load the package with a dynamic import().