Application fails to start with SyntaxError: Unexpected token '?'

  • Updated


The following error is presented upon starting your application with the v5 Node agent:

for (const svcName of installOrder ?? []) {

SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/contrast/agent/node_modules/@contrast/agent/lib/index.js:27:18)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)


The nullish coalescing (??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand. The nullish coalescing operator works with Node.js >= 14, and the Contrast v5 Node agent supports Node.js LTS versions 16, 18, and 20.


There are two solutions to remediate this issue:

  1. Upgrade the Node.js version for your project. We recommend upgrading the Node.js version for your project in accordance with best practices. Utilizing the active LTS versions of Node.js is advised to mitigate potential security vulnerabilities.
  2. Use the legacy v4 Node agent
    1. Legacy - Supported technologies for v4
    2. npm - Latest v4 agent




Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request