nestjs-redis
nestjs-redis copied to clipboard
🐛Nest can't resolve dependencies forRootAsync
Package
@nestjs-redis/kit
Version
0.12.1
What happened?
RedisModule.forRootAsync({
inject: [ConfigService],
useFactory(configService: ConfigService) {
const username = configService.getOrThrow('redis.username');
const password = configService.getOrThrow('redis.password');
const host = configService.getOrThrow('redis.host');
const port = configService.getOrThrow('redis.port');
const db = configService.getOrThrow('redis.db');
return {
options: {
url: `redis://${username}:${password}@${host}:${port}/${db}`,
},
};
},
}),
RedlockModule.forRootAsync({
inject: [RedisToken()],
useFactory: (redis ) => ({ clients: [redis] }),
})
it gives me error:
UnknownDependenciesException [Error]: Nest can't resolve dependencies of the REDLOCK_MODULE_OPTIONS (?). Please make sure that the argument "REDIS_CLIENT" at index [0] is available in the RedlockModule context.
Potential solutions:
- Is RedlockModule a valid NestJS module?
- If "REDIS_CLIENT" is a provider, is it part of the current RedlockModule?
- If "REDIS_CLIENT" is exported from a separate @Module, is that module imported within RedlockModule? @Module({ imports: [ /* the Module containing "REDIS_CLIENT" */ ] })
Steps to reproduce
- install package
- import in app module
Code example
Environment
Node.js: NestJS: Redis: