@nestjs/jwt-无法读取属性';挑战';未定义的

@nestjs/jwt-无法读取属性';挑战';未定义的,jwt,nestjs,Jwt,Nestjs,我在我的nestjs应用程序中使用jwt令牌,但当我运行我的项目并使用@UseGuards(AuthGuard())decorator调用控制器时,应用程序调试返回以下错误: Cannot read property 'challenge' of undefined 而不是这一行: @UseGuards(AuthGuard()) 使用这个: @UseGuards(AuthGuard('jwt')) 您必须导入PassportModule作为 imports: [ TypeOrm

我在我的
nestjs
应用程序中使用
jwt
令牌,但当我运行我的项目并使用
@UseGuards(AuthGuard())
decorator调用控制器时,应用程序调试返回以下错误:

Cannot read property 'challenge' of undefined
而不是这一行:

@UseGuards(AuthGuard())
使用这个:

@UseGuards(AuthGuard('jwt'))

您必须导入
PassportModule
作为

  imports: [
    TypeOrmModule.forFeature([UserRepository]),
    HttpModule,
    ConfigModule,
    PassportModule.register({ defaultStrategy: 'jwt' }),
  ],
进入要使用默认策略的每个模块