RichCorbs
RichCorbs•5mo ago

Deno 2.0: Deno.write is not a function

I'm trying to use a 3rd party package with Deno 2 and get this error:
error: Uncaught (in promise) TypeError: Deno.write is not a function
await Deno.write(this.writer.rid, headers);
^
at Writer.setup (https://deno.land/x/compress@v0.4.6/gzip/writer_gzip.ts:41:16)
at eventLoopTick (ext:core/01_core.js:175:7)
at async GzipStream.compress (https://deno.land/x/compress@v0.4.6/gzip/gzip_stream.ts:21:5)
error: Uncaught (in promise) TypeError: Deno.write is not a function
await Deno.write(this.writer.rid, headers);
^
at Writer.setup (https://deno.land/x/compress@v0.4.6/gzip/writer_gzip.ts:41:16)
at eventLoopTick (ext:core/01_core.js:175:7)
at async GzipStream.compress (https://deno.land/x/compress@v0.4.6/gzip/gzip_stream.ts:21:5)
I've opened an issue and the maintainer is unable to help at this time. I have tried to fix it but have been unable. Is there anything obvious that changed in Deno 2.0 that would indicate a obvious fix to someone who knows what they're doing? Like replace Deno.write with ??? or similar?
3 Replies
bartlomieju
bartlomieju•5mo ago
Yes, Deno.write has been deprecated and removed in Deno 2
RichCorbs
RichCorbsOP•5mo ago
Thanks I'll take another look this evening. I got into that 3rd party package and realized that the fix was going to be way more complicated than just using constructs from the std library. A few lines of understandable code later and I have exactly what I need without another dependency. Shoutout to Deno for being so simple to use!
bartlomieju
bartlomieju•5mo ago
Happy to hear that! When in doubt always check @std 😉

Did you find this page helpful?