Skip to content

SyntaxError: Unexpected token '?' on Amazon Linux 2 CodeBuild images (Node 14 required starting at 2.28.0) #20739

@wr-cdargis

Description

@wr-cdargis

Describe the bug

Running command cdk synth with latest aws-cdk from npm produces an error.

Expected Behavior

I made no changes to source. The install step installs the most recent aws-cdk and it seems this error came with the newest version.

Current Behavior

[Container] 2022/06/14 18:50:24 Running command cdk synth
--
663 | /usr/local/lib/node_modules/aws-cdk/lib/index.js:12322
664 | return process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : path.join((os.userInfo().homedir ?? os.homedir()).trim() \|\| "/", ".cdk");

SyntaxError: Unexpected token '?'
--
668 | at wrapSafe (internal/modules/cjs/loader.js:915:16)
669 | at Module._compile (internal/modules/cjs/loader.js:963:27)
670 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
671 | at Module.load (internal/modules/cjs/loader.js:863:32)
672 | at Function.Module._load (internal/modules/cjs/loader.js:708:14)
673 | at Module.require (internal/modules/cjs/loader.js:887:19)
674 | at require (internal/modules/cjs/helpers.js:74:18)
675 | at Object.<anonymous> (/usr/local/lib/node_modules/aws-cdk/bin/cdk.js:3:15)
676 | at Module._compile (internal/modules/cjs/loader.js:999:30)
677 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

Reproduction Steps

npm install -g aws-cdk
cdk synth

Possible Solution

No response

Additional Information/Context

I was able to explicitly install version 2.27.0 to confirm this is an issue with 2.28.0 (but I still have this problem later in the self mutate phase where I can't control the version). This was all done on a .NET CDK app. My apologies for the lack of info I know you need more I am just trying to get some attention on this as soon as I can.

CDK CLI Version

aws-cdk@2.28.0

Framework Version

No response

Node.js Version

12.22.12

OS

Linux

Language

.NET

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions