Cannot find name 'ReadableStream'.
See original GitHub issueDescribe the bug
Cannot find name 'ReadableStream'.
Your environment
SDK version number
@aws-sdk/client-s3@3.42.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
node -v
v16.13.0
Steps to reproduce
import {S3} from "@aws-sdk/client-s3";
(async () => {
const s3Client = new S3({});
const data = (await s3Client.getObject({
"Bucket": "mybucket",
"Key": "data.txt"
}));
console.log(data.Body);
})();
Observed behavior
node_modules/@aws-sdk/client-s3/dist-types/models/models_0.d.ts:6050:23 - error TS2304: Cannot find name 'ReadableStream'.
6050 Body?: Readable | ReadableStream | Blob;
~~~~~~~~~~~~~~
node_modules/@aws-sdk/client-s3/dist-types/models/models_0.d.ts:6697:23 - error TS2304: Cannot find name 'ReadableStream'.
6697 Body?: Readable | ReadableStream | Blob;
~~~~~~~~~~~~~~
node_modules/@aws-sdk/client-s3/dist-types/models/models_0.d.ts:9081:23 - error TS2304: Cannot find name 'ReadableStream'.
9081 Body?: Readable | ReadableStream | Blob;
~~~~~~~~~~~~~~
node_modules/@aws-sdk/client-s3/dist-types/models/models_1.d.ts:837:23 - error TS2304: Cannot find name 'ReadableStream'.
837 Body?: Readable | ReadableStream | Blob;
~~~~~~~~~~~~~~
node_modules/@aws-sdk/client-s3/dist-types/models/models_1.d.ts:1116:23 - error TS2304: Cannot find name 'ReadableStream'.
1116 Body?: Readable | ReadableStream | Blob;
~~~~~~~~~~~~~~
Expected behavior
No TypeScript errors
Screenshots

Additional context
Also, when running this code, it doesn’t print the contents, but instead a large object that looks like a response object. It should print the contents of the file.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:10
Top Results From Across the Web
Typescript doesn't compile due to error TS2304: Cannot find ...
Turned out that in order for typescript to find the Blob , File etc. names I had to add the dom entry to...
Read more >Error: node_modules/@aws-sdk/client-s3/types/S3Client.d.ts ...
Error: node_modules/@aws-sdk/client-s3/types/models/models_0.d.ts (5436,23): Cannot find name 'ReadableStream'.
Read more >aws/aws-sdk-js-v3 - Gitter
Is it possible to create a readable stream from the S3 client, like it was in v2 of the SDK? I've been digging...
Read more >Can't deug NodeJs Console App - Visual Studio Feedback
Hi, I can't debug NodeJs console app cause I got output like that: ------ Build started: Project: NodejsConsoleApp1, Configuration: Debug Any CPU ...
Read more >Creating and using Amazon S3 buckets - AWS Documentation
This sample code can be found here on GitHub . Creating an Amazon S3 bucket. Create a libs directory, and create a Node.js...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Adding
"dom"
to the libs section of yourtsconfig.json
is not a solution. If you are writing constructs with aws jsii thetsconfig.json
is generated and not editable. This dependency makes it unusable in non-browser environments in my opinion.The other option is to use declaration merging to stub out the missing interface that aws-sdk assumes is available. Add this where you are exporting code that uses the SDK:
That should allow you to compile without hauling in the entire DOM lib.