I'm using v3 of the AWS SDK for javascript in a typescript/nodejs environment, but when I run it with ts-node, it plains 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 mand = new ListObjectsCommand({
Bucket: bucket,
Prefix: prefix,
});
const result = await client.send(mand);
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 pile 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-pose container. Other code works fine, including a mand to get a signedURL using the same client object.
I'm using v3 of the AWS SDK for javascript in a typescript/nodejs environment, but when I run it with ts-node, it plains 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 mand = new ListObjectsCommand({
Bucket: bucket,
Prefix: prefix,
});
const result = await client.send(mand);
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 pile 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-pose container. Other code works fine, including a mand to get a signedURL using the same client object.
Share Improve this question asked Feb 17, 2022 at 22:55 whiterook6whiterook6 3,5543 gold badges42 silver badges86 bronze badges 4- S3Client config does not have a credentialDefaultProvider parameter. – kevintechie Commented Feb 17, 2022 at 23:56
- @kevintechie removing that line doesn't fix the pilation issue. – whiterook6 Commented Feb 18, 2022 at 0:09
- Have you inspected the client variable? What does TS think it is? Probably need all code to debug further. – kevintechie Commented Feb 18, 2022 at 0:27
- @kevintechie I am getting the same error just running the examples from npmjs./package/@aws-sdk/client-s3 inside a TypeScript file – Simon Commented Feb 18, 2022 at 2:08
1 Answer
Reset to default 6We 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.