NestJS can't resolve dependencies of the JWT_MODULE_OPTIONS

前端 未结 3 1472
你的背包
你的背包 2021-01-24 16:02

I\'m failed to compile with this error:

Nest can\'t resolve dependencies of the JWT_MODULE_OPTIONS (?). Please make sure that the argument at index [0] is available

3条回答
  •  不知归路
    2021-01-24 16:22

    I somehow got it to work by adding

    JwtModule.registerAsync({
      imports: [ConfigModule], // Missing this
      useFactory: async (configService: ConfigService) => ({
        signOptions: {
           expiresIn: config.expiresIn,
        },
        secretOrPrivateKey: config.jwtSecret,
      }),
      inject: [ConfigService], 
    }),
    

    in the app.module.ts and auth.module.ts

提交回复
热议问题