Skip to content

🐛Nest can't resolve dependencies forRootAsync #10

@PBird

Description

@PBird

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

  1. install package
  2. import in app module

Code example

Environment

Node.js:
NestJS:
Redis:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions