2022. 1. 31. 12:02ㆍErrors
ERROR [ExceptionHandler] Nest can't resolve dependencies of the JwtService (?). Please make sure that the argument JWT_MODULE_OPTIONS at index [0] is available in the UsersModule context.
Potential solutions:
- If JWT_MODULE_OPTIONS is a provider, is it part of the current UsersModule?
- If JWT_MODULE_OPTIONS is exported from a separate @Module, is that module imported within UsersModule?
@Module({
imports: [ /* the Module containing JWT_MODULE_OPTIONS */ ]
})
Error: Nest can't resolve dependencies of the JwtService (?). Please make sure that the argument JWT_MODULE_OPTIONS at index [0] is available in the UsersModule context.
Potential solutions:
- If JWT_MODULE_OPTIONS is a provider, is it part of the current UsersModule?
- If JWT_MODULE_OPTIONS is exported from a separate @Module, is that module imported within UsersModule?
@Module({
imports: [ /* the Module containing JWT_MODULE_OPTIONS */ ]
})
import { JwtTokenReturn } from './../../types';
import { Module } from '@nestjs/common';
import { UsersService } from './services/users.service';
import { UsersController } from './users.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './entities/user.entity';
import { UserRepo } from './dao/user.dao';
import { JwtModule, JwtService } from '@nestjs/jwt';
@Module({
imports: [TypeOrmModule.forFeature([User])],
controllers: [UsersController],
providers: [UsersService, UserRepo, JwtService],
exports: [UsersService],
})
export class UsersModule {}
////////////////////////////////////////////////////////////
Providers에 JwtService를 주입 했는데도 불구하고, 위와 같은 에러가 났다.
한참을 검색을 하다가,
imports: [TypeOrmModule.forFeature([User]), JwtModule.register({})],
providers에 JwtService를 지우고,
import에 JwtModule.register({})를 추가 해줬더니 해결이 되었다.