node.jssyntax-erroraws-sdk-nodejsnull-coalescing-operatoroptional-chaining

SyntaxError: Unexpected token '.' for optional chaining and Nullish coalescing


The issue was encountered after installing the aws s3 sdk.

I followed the suggested solutions from all other similar problems in the following manner: -updated node version (even though I had version 18 which supports optional chaining and nullish coalescing) -installed babel's plugins i.e. both transform and syntax plugins for optional chaining and nullish coalescing

The issue still remains.

snippet of the error is as follows:

bodyLengthChecker: config?.bodyLengthChecker ?? util_body_length_node_1.calculateBodyLength,
                              ^
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> (/home/ubuntu/VGS/node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js:19:25)

Would really like some assistance here. Please ask me for any information that you require to further clarify the situation.

As mentioned before I tried the suggested solutions, but the issue remained.


Solution

  • Yes.Minimum Node version 14 is required for optional chaining