Module imports

Lists other modules whose exported providers become available in the current module.

Since NestJS 10/11 Spec ↗

Syntax

imports: [Module | DynamicModule | Promise<DynamicModule>]

Returns

any[] — Entries declared in a module metadata imports array.

Examples

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Cat } from './cat.entity';

@Module({
  imports: [TypeOrmModule.forFeature([Cat])],
})
export class CatsModule {}

Notes

Importing a module exposes only its exported providers, not its internal ones. Dynamic modules use static methods like forRoot() or forFeature() to return configured module definitions.