NestJS fails to lazily inject third-party dependencies. I've tested with both nest-mongodb and @golevelup/nestjs-rabbitmq, here is a reproduction with the former: https://github.com/timm-stelzer-e-farm/nestjs-dependency-injections-issue. Running start:lazy fails with:
UnknownDependenciesException [Error]: Nest can't resolve dependencies of the DatabaseService (?). Please make sure that the argument fooDb at index [0] is available in the DatabaseModule context.
Potential solutions:
- If fooDb is a provider, is it part of the current DatabaseModule?
- If fooDb is exported from a separate @Module, is that module imported within DatabaseModule?
@Module({
imports: [ /* the Module containing fooDb */ ]
})
at Injector.lookupComponentInParentModules (/<path>/node_modules/@nestjs/core/injector/injector.js:241:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Would expect both start:eager and start:lazy to work as expected.
I created an issue at https://github.com/nestjs/nest/issues/10458, which was closed, which I guess means its on my end? Would appreciate some pointers.