Atul Chaudhary
Atul Chaudhary

Reputation: 3736

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

Upvotes: 6

Views: 834

Answers (1)

Kim Kern
Kim Kern

Reputation: 60347

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.

Upvotes: 1

Related Questions