'Unable to compile Typescript: property send does not exist on s3client

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source