Skip to content
← Back to activity

Public problem

SyntaxError: Unexpected token '?' running cdk synth on Amazon Linux 2 CodeBuild (Node 14 required since...

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Running cdk synth on an Amazon Linux 2 CodeBuild image started failing with SyntaxError: Unexpected token '?', pointing at the compiled aws-cdk CLI JavaScript. Nothing in the project had changed; the install step just pulled the newest aws-cdk. The cause was that aws-cdk 2.28.0 raised its Node requirement to >= 14.15.0 (it uses the ?? operator), while the Amazon Linux 2 build images only ship Node 12, and the ARM images had no newer option at all.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

aws-cdk 2.28.0 and later require Node.js 14.15.0 or newer, which the Amazon Linux 2 CodeBuild images do not provide. The verified workaround is to install a newer Node in the build's install phase with the n version manager, e.g. add an install command like n 16.15.1 before running cdk commands. The reporter confirmed this unblocked their pipeline. Longer term, move to a CodeBuild image with a newer Node runtime. Source: https://github.com/aws/aws-cdk/issues/20739