skunight/nestjs-redis

Nest can't resolve dependencies of the RedisCoreModule (Symbol(REDIS_MODULE_OPTIONS), ?). Please make sure that the argument ModuleRef at index [1] is available in the RedisCoreModule context.

Opened this issue · 23 comments

// config.ts
export const redisConfig: RedisModuleOptions = {
  url: 'redis://treehole:redis@localhost:6379/1',
}
import databaseConfig, { redisConfig } from './config/database.config'

@Module({
  imports: [TypeOrmModule.forRoot(databaseConfig), UserModule, AuthModule, RedisModule.register(redisConfig)],
  controllers: [],
  providers: [],
})
export class AppModule {}

But it gave me an error

[Nest] 35656  - 2022/02/14 下午3:50:35   ERROR [ExceptionHandler] Nest can't resolve dependencies of the RedisCoreModule (Symbol(REDIS_MODULE_OPTIONS), ?). Please make sure that the argument ModuleRef at index [1] is available in the RedisCoreModule co
ntext.

Potential solutions:
- If ModuleRef is a provider, is it part of the current RedisCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within RedisCoreModule?
  @Module({
    imports: [ /* the Module containing ModuleRef */ ]
  })

Error: Nest can't resolve dependencies of the RedisCoreModule (Symbol(REDIS_MODULE_OPTIONS), ?). Please make sure that the argument ModuleRef at index [1] is available in the RedisCoreModule context.

Potential solutions:
- If ModuleRef is a provider, is it part of the current RedisCoreModule?
- If ModuleRef is exported from a separate @Module, is that module imported within RedisCoreModule?
  @Module({
    imports: [ /* the Module containing ModuleRef */ ]
  })

    at Injector.lookupComponentInParentModules (C:\Dev\hfut-tree-hole\nest\node_modules\@nestjs\core\injector\injector.js:202:19)
    at Injector.resolveComponentInstance (C:\Dev\hfut-tree-hole\nest\node_modules\@nestjs\core\injector\injector.js:157:33)

What happen? And what should i do to solve it? I'm sure that the redis server is no wrong.

same issue here

same here, seems to be issue with nest 8

same issue here

same here

same issue

same

same issue

Same here

Same here

same here

Same here

Fixed by using @liaoliaots/nestjs-redis instead.

same issue

一样的问题

这个包是不维护了吗?

Is this resolved yet?

Is this resolved yet?

i resolved by change package.json to
"nestjs-redis": "github:skunight/nestjs-redis",

same issue

same issue

For anyone having this issue, I resolved this by switching over to https://www.npmjs.com/package/@liaoliaots/nestjs-redis.

issue is caused by @nestjs/core and other nestjs libraries in nestjs-redis package.json dependencies. It should be moved to peer dependencies.

I guess Nest.js is trying to inject ModuleRef from nestjs-redis/@nestjs/core instead of @nestjs/core installed in your app.