Class constructor Construct cannot be invoked without 'new' – aws cdk


I have an NPM library here that will be used across multiple CDK apps and AWS accounts

export class FrontendConstruct extends Construct {
  constructor(parent: Construct, id: string, props: FrontendConstructProps) {
    super(parent, id);

//creating s3 bucket etc
//create cloudfront cdn

Here is my stack on the cdk app using it

import * as ssFE from '@customnpmlibrary/cdk-ss-fe'

export interface stFrontendStackProps extends cdk.StackProps {
   * The domain name for the site to use
  readonly domainName: string;
 * Location of FE code to deploy
  readonly deploymentSource: string;

export class stFrontendStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: stFrontendStackProps) {
    super(scope, id,props);

    new ssFE.FrontendConstruct 
      (this, 'stfeStack', {
      domainname: props.domainName,
      deploymentSource: props.deploymentSource

and creating the app

import { stFrontendStack } from '../lib/st-frontend-stack';

const app = new cdk.App();

new stFrontendStack(app, 'stFrontend-DEV', {
  env: {
    account: '1234',
    region: 'us-east-1'
  domainName: '',

when I go to deploy it I get this: during cdk synth

Class constructor Construct cannot be invoked without 'new'

Any thoughts or help?


The problem here is with your ECMAScript version. This can be fixed by using ES2018 in your tsconfig.json as follows:

  "compilerOptions": {
    "module": "commonjs",
    "lib": ["es2018"],
    ... any other options ...

Also, I ran into an issue when running tsc with parameters. You need to make sure that tsc is picking up the tsconfig.json properly. For me, removing parameters from tsc solved the issue.

Answered By – Jared Bates

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published