Ncc: TypeError: Class constructor ... cannot be invoked without 'new'

Created on 26 Feb 2019  路  3Comments  路  Source: vercel/ncc

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?

Most helpful comment

The problem is fixed when defining "target": "es6" in compilerOptions of tsconfig.json

All 3 comments

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guybedford picture guybedford  路  5Comments

GiladShoham picture GiladShoham  路  3Comments

andykais picture andykais  路  4Comments

rauchg picture rauchg  路  3Comments

tmtron picture tmtron  路  5Comments