Class constructor MixinStrategy cannot be invoked without 'new'
See original GitHub issueI’m submitting a…
[ ] Regression
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Class constructor MixinAuthGuard cannot be invoked without ‘new’
Expected behavior
normal
auth.module.ts
import { Module } from "@nestjs/common";
import { PassportModule } from "@nestjs/passport";
import { JwtModule } from "@nestjs/jwt";
import { AuthService } from "@modules/auth/auth.service";
import { JwtStrategy } from "@services/jwt.strategy";
import { AuthController } from "./auth.controller";
@Module({
controllers: [AuthController],
imports: [
PassportModule.register({ defaultStrategy: "jwt" }),
JwtModule.register({
secretOrPrivateKey: "secretKey",
signOptions: {
expiresIn: 3600,
},
})
],
providers: [AuthService, JwtStrategy],
exports: [PassportModule, JwtModule],
})
export class AuthModule { }
jwt.strategy.ts
import { Injectable, UnauthorizedException } from "@nestjs/common";
import { PassportStrategy } from "@nestjs/passport";
import { ExtractJwt, Strategy } from "passport-jwt";
import { AuthService } from "@modules/auth/auth.service";
import { IJwtPayload } from "./interfaces/jwt.payload";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
private readonly authService: AuthService,
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: "secretKey",
});
}
public async validate(payload: IJwtPayload) {
const user = await this.authService.validateUser(payload);
if (!user) {
throw new UnauthorizedException();
}
return user;
}
}
Environment
Nest version: 6.2.0
For Tooling issues:
- Node version: 10.15.3
- Platform: mac
Others:
I use platform-fastify
package.json
{
"dependencies": {
"@nestjs/common": "^6.2.0",
"@nestjs/core": "^6.2.0",
"@nestjs/jwt": "^6.0.0",
"@nestjs/passport": "^6.0.0",
"@nestjs/platform-express": "^6.2.0",
"@nestjs/platform-fastify": "^6.2.0",
"@nestjs/typeorm": "^6.1.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"pg": "^7.11.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.2",
"typeorm": "^0.2.17"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/passport-jwt": "^3.0.1",
"nodemon": "^1.19.0",
"ts-node": "^8.1.0",
"tsconfig-paths": "^3.8.0",
"tslint": "^5.16.0",
"typescript": "^3.4.5"
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
TypeError: Class constructor MixinStrategy cannot be invoked ...
Of which I have no idea what it means! Anyone any ideas? TypeError: Class constructor MixinStrategy cannot be invoked without 'new' 8 | ......
Read more >Class constructor cannot be invoked without 'new' in TS
The "Class constructor cannot be invoked without new" error occurs when the target property in tsconfig.json is set to lower than es6 or...
Read more >Class constructor Positions cannot be invoked without 'new'
I am trying to create an instance of one class that extends from another. ... Class constructor Positions cannot be invoked without 'new'....
Read more >에러) Class constructor MixinStrategy cannot be ... - 도전맨
에러) Class constructor MixinStrategy cannot be invoked without 'new' +461ms · 블로그 정보.
Read more >Nestjs And Typeorm Issue With Or Without Tsconfig Target Es5
Class constructor MixinStrategy cannot be invoked without 'new. May 08, 2021 auth.module.ts import { Module } from "@nestjs/common"; import tsconfig target.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Change
target
toes6
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.