I'm using v3 of the AWS SDK for javascript in a typescript/nodejs environment, but when I run it with ts-node, it complains about being unable to find the send function on the s3client. My code:
const client = new S3Client({
credentialDefaultProvider: this.getCredentialDefaultProvider
region: "us-west-2",
});
const command = new ListObjectsCommand({
Bucket: bucket,
Prefix: prefix,
});
const result = await client.send(command);
The error I get when starting my server is this:
/server/node_modules/ts-node/src/index.ts:230
return new TSError(diagnosticText, diagnosticCodes)
TSError: ⨯ Unable to compile TypeScript:
src/controllers/aws.controller.ts(56,37): error TS2339: Property 'send' does not exist on type 'S3Client'.
This is basically the same as the code samples in the official documentation. But I have installed the correct packages (and even cleared my node_modules folder and reinstalled it) and the code in node_modules looks correct. What am I doing wrong?
For context, this is a nodeJS script running in ts-node in a docker-compose container. Other code works fine, including a command to get a signedURL using the same client object.
We got the same error with a fresh (v3.51.0) @aws-sdk\client-s3 module but not with the older v3.47.0. Downgraded the @aws-sdk\client-s3 module to v3.47.0 and our worries were gone.