CodeZettaInterview Hub

NestJS · Modules · Junior · Comparison

imports vs exports vs providers in @Module — differences?

Short Interview Answer

providers: created in this module; exports: make providers available to importers; imports: bring in other modules' exports.

Detailed Explanation

Forgetting to export a shared service is a classic DI error. Controllers are not exported — only providers are.

Common Mistake

Importing a module but not exporting the service you need from it.

Did you know this answer?