Node @aws-sdk/client-s3 throws an error at import: options.useFipsEndpoint ?? false (Invalid or unexpected token)
SamyGarib opened this issue · 1 comments
Describe the bug
I'm runing Node 20.14.0 and aws-sdk/client-s3 ^3.609.0
The error occurs just when I import the library:
const { PutObjectCommand, S3Client } = require("@aws-sdk/client-s3");
/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:282 useFipsEndpoint: options.useFipsEndpoint ?? false
Invalid or unexpected token (it points to ??)
To double check I'm using the correct runtime I added this line to my script:
console.log(Node.js version: ${process.version}
);
Expected Behavior
It shouldn't have thrown an error.
Current Behavior
node_modules/@aws-sdk/client-s3/dist-cjs/index.js:282 useFipsEndpoint: options.useFipsEndpoint ?? false, SyntaxError: Invalid or unexpected token at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
Reproduction Steps
const { S3Client } = require("@aws-sdk/client-s3");
Possible Solution
No response
Additional Information/Context
No response
SDK version used
v3
Environment details (OS name and version, etc.)
Linux (ubuntu 24.04), 6.8.0-36-generic
This issue happened because I was calling the script with esm flag, like
"node -r esm download.js"
I don't know If this should work either way, but I managed to make it work so I'm closing the tickets.