With this code in AuthService:
@Injectable()
AuthService {
constructor(
@InjectRepository(UserRepository)
private jwtService: JwtService
private userRepository: UserRepository
) {
}
async login(loginCredentialsDto: LoginCredentialsDto): Promise<{ accessToken: string }> {
const email = await this.userRepository.validatePassword(loginCredentialsDto);
const payload: JwtPayLoad = {email};
return {
accessToken: this.jwtService.sign(payload),
};
}
}
Once it is compiled during runtime I get the following error:
[Nest] 12998 - 07/03/2020, 9:22:20 PM [ExceptionsHandler] this.jwtService.sign is not a function +213303ms
Following is the AuthModule:
@Module({
imports: [
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.register({
secret: 'topSecret51',
signOptions: {
expiresIn: 3600,
}
}),
TypeOrmModule.forFeature([UserRepository])],
controllers: [AuthController],
providers: [AuthService, JwtStrategy],
exports: [
JwtStrategy,
PassportModule,
], })
export class AuthModule { }
Any ideas how this can be resolved?
I have re-installed npm, removed node modules and tried to modify code. But it still does not work.