What is a Nest Module?

Nest provides modules that are high-level components in the application. Modules are introduced to organize reusable features and make the organization of applications effective.

The module is a Typescript class annotated with @module decorator.

@module decorator contains module metadata of how components are exposed and used by other components.

NestJS application has at least one module, the Root module located in app.module.ts.

How to create a module

The root module is created with application creation.

You can create your module using the below command.

nest g mo employee

It created a file employee.module.ts under a folder employee.

import { Module } from '@nestjs/common';

 controllers: [],
 providers: [],
export class EmployeeModule {}

Updated this module in root module app.module.ts

import { Module } from '@nestjs/common';
import { EmployeeModule } from './employee/employee.module';

  imports: [EmployeeModule],
export class AppModule {}