NestJS builds the module graph depth-first starting from the root module. Imported modules are always initialized before the module that imports them — dependencies are ready before their consumers. You cannot manually control the order but can rely on lifecycle hooks like OnModuleInit to run logic after all providers are instantiated.
NestJS initializes modules depth-first — deepest dependencies initialize first.
Imported modules are always ready before the module that imports them.
You cannot manually set initialization order — structure your imports to express the correct dependency direction.
Use OnModuleInit for post-initialization logic — it fires after all providers in the module are instantiated.
Use OnApplicationBootstrap for logic that must run after every module in the app is initialized.