Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CDK: Unexpected token '?'

Tags:

aws-cdk

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?

like image 890
Leon Hsu Avatar asked Jun 06 '26 10:06

Leon Hsu


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.

like image 147
Oliver Avatar answered Jun 10 '26 16:06

Oliver


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,
    ...
  }
}
like image 25
Leon Hsu Avatar answered Jun 10 '26 16:06

Leon Hsu