AWS CDK: Unexpected token '?'

Viewed 4434

When I upgraded from 1.33.0 -> 1.37.0, I started getting the error below. I reverted back to the old CDK version, and the command works again.

CDK version

$ cdk --version
1.37.0 (build e4709de)

Error:

$ cdk synth
Unexpected token '?'
Subprocess exited with error 1

Any insight as to what this error message could mean?

2 Answers

Another cause for this issue could be an outdated node version, CDK support for node 12 has been dropped in this release.

Upgrading to a supported node version resolves the issue.

The issue was in the typescript compiler. I had the target set to ES2020 when it should've been ES2018.

Changing to the correct version fixed the issue for me.

tsconfig.json

{
  "compilerOptions": {
    "target":"ES2018",
    "module": "commonjs",
    "lib": ["es2018"],
    "declaration": true,
    "strict": true,
    ...
  }
}
Related