Reproduction
The constructor requests a class decorated with @Injectable(), but the owner Module neither registers nor imports a matching Provider:
import { Command, Handler, Injectable, Module, createApp } from 'func'
@Injectable()
class RegistryClient {}
@Command('publish')
class PublishCommand {
constructor(private registry: RegistryClient) {}
@Handler()
run() {}
}
@Module({ commands: [PublishCommand] })
class AppModule {}
createApp(AppModule)What this error means
The runtime has resolved the dependency token, but no corresponding Provider is visible from the requesting Module. details.token is the missing token and details.requester is the requesting Module. Nested dependencies also include dependencyPath.
Providers are private to their Module by default. An imported Module must list a token in exports before its consumer can resolve it, and every intermediate Module must re-export the token for it to travel farther. A feature option Provider that is inactive for the current command is not exposed as an ordinary dependency either.
How to fix it
Register the Provider in the requesting Module:
@Module({
commands: [PublishCommand],
providers: [RegistryClient],
})
class AppModule {}If the Provider belongs to another Module, add both providers: [RegistryClient] and exports: [RegistryClient] there, then import that Module from the requester. For interfaces and other non-class dependencies, use createToken() with @Inject(token) and register that same token.