n.prototype.customizeRequests is not a function at requiring s3

Viewed 70

I am using aws s3 to upload zip files. I have created the s3 client object as:

const client = s3.createClient({ s3Client: awsS3Client })

But when I run the code, it throws an error and never reaches to this line or anywhere below the require statement for s. i.e: const s3 = require('s3') & throws following error:

{ "errorMessage": "n.prototype.customizeRequests is not a function", "errorType": "TypeError", "stackTrace": [ "TypeError: n.prototype.customizeRequests is not a function", " at /serverless_sdk/index.js:9:205226", " at Object.<anonymous> (/node_modules/s3/lib/index.js:1:11)" ]}

This is happening after updating the NodeJS to any of the versions above version 10.

1 Answers

Try :

import { S3 } from 'aws-sdk';

or if you use SDK v3 :

const { S3Client } = require("@aws-sdk/client-s3");
const client = new S3Client(clientParams);
Related