I am trying out ncc with a nestjs project. So, I did a build with ncc for the project.
But when I run the project I get an error:
[Nest] 9604 - 2019-2-26 07:29:02 [ExceptionHandler] Class constructor MixinAuthGuard cannot be invoked without 'new' +1ms
TypeError: Class constructor MixinAuthGuard cannot be invoked without 'new'
at new SecurityGuard (C:\devtemp\vb\dist\index.js:21554:28)
at Injector.instantiateClass (C:\devtemp\vb\dist\index.js:109334:19)
at callback (C:\devtemp\vb\dist\index.js:109187:41)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
1: 00007FF684860EFA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810
2: 00007FF68483A296 node::MakeCallback+4518
3: 00007FF6847AF889 v8::internal::StackGuard::ArchiveSpacePerThread+18441
4: 00007FF68506ADD2 v8::internal::OptimizingCompileDispatcher::Unblock+60562
5: 00007FF68506C26D v8::internal::OptimizingCompileDispatcher::Unblock+65837
6: 00007FF68506B2C9 v8::internal::OptimizingCompileDispatcher::Unblock+61833
7: 00007FF68506B1AB v8::internal::OptimizingCompileDispatcher::Unblock+61547
8: 00000068468DC5C1
The sourcecode which is responsible for the error is the following
import { ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { AuthGuard } from '@nestjs/passport';
...
export class SecurityGuard extends AuthGuard('jwt') {
}
Can anybody give me a hint how to solve the problem?
The problem is fixed when defining "target": "es6" in compilerOptions of tsconfig.json
This answer dont resolves. My tsconfig.json always have been with "target": "es6".
This answer dont resolves. My tsconfig.json always have been with "target": "es6".
Did you get a solution to this error?
Most helpful comment
The problem is fixed when defining "target": "es6" in compilerOptions of tsconfig.json