@Global() registers the module's exported providers into the global DI scope. Any module in the application can inject those providers without listing the module in its own imports array. The global module must still be imported once — typically in AppModule — to be registered.
The module must still be imported once — usually in AppModule — to be registered in the container.
After registration, its exports are available to every module without explicit imports.
Only providers listed in exports are available globally — providers not exported remain private.
Use @Global() sparingly — it hides dependencies and makes modules harder to test in isolation.
You need a ConfigService available in many feature modules without importing ConfigModule everywhere. How would you set it up using @Global()?
If you add @Global() to a module but forget to export a provider, what will happen when another module tries to inject it?
During a sprint you refactor a shared LoggerModule to be global. After the change, a feature module that previously imported LoggerModule starts throwing a circular dependency error. Why might that happen?
You notice that a unit test for a controller fails because a globally provided AuthService is not mocked. How would you adjust the test setup to handle the global provider?
Your team is scaling a microservice architecture and wants to avoid importing common utility modules in each NestJS microservice. Discuss the trade‑offs of making those modules global versus using a shared library.
A performance audit shows that a globally scoped provider is instantiated multiple times unexpectedly. Explain how NestJS handles provider scope with @Global() and how you would fix the issue.
Looking ahead, you need to migrate several legacy NestJS applications into a monorepo. Some of them rely on global modules. How would you design a strategy to manage global providers to keep the monorepo maintainable and avoid hidden coupling?
Your organization wants to enforce a policy that only certain core services can be global. Propose an architectural guideline and tooling approach to audit and enforce correct usage of @Global() across many teams.