Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJS and TypeORM issue with or without tsconfig target es5

As per NestJS authentication tutorial I copy pasted the JwtStrategy class but that class throws an error at build time

Class code is

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor(private readonly userRepo: UserRepository) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      secretOrKey: 'secretKey'
    });
  }
}

And with target=es5 in tsconfig.json file the error I get

enter image description here

Now if I change the target to es6 error goes away but then typeorm many to many relationship start throwing an error

TypeORM class User got tokens and Token class got user and it throws the error below

enter image description here

I have created the repository to reproduce the error at this link

run following command to see the error

ng s --project=api
like image 580
Atul Chaudhary Avatar asked May 02 '19 13:05

Atul Chaudhary


1 Answers

You are mixing nest v5 and nest v6 although different major versions are not guaranteed to interoperate properly, e.g.:

"@nestjs/core": "5.5.0",
"@nestjs/jwt": "^6.0.0",

Please update all your @nestjs dependencies to version 6 following the migration guide.

like image 187
Kim Kern Avatar answered Oct 20 '22 03:10

Kim Kern