Sometimes, we want to fix Node.js can’t create Blobs with JavaScript.
In this article, we’ll look at how to fix Node.js can’t create Blobs with JavaScript.
How to fix Node.js can’t create Blobs with JavaScript?
To fix Node.js can’t create Blobs with JavaScript, we can import it from the node:buffer module since Node 16.
To use it, we write
import { Blob } from "node:buffer";
const b = new Blob([]);
to import the Blob constructor with
import { Blob } from "node:buffer";
Then we use it to create the b Blob object.
We can use the cross-blob module if our app runs with older versions of Node.
To install it, we run npm i cross-blob.
Then we use it by writing
import Blob from "cross-blob";
const b = new Blob([]);
Conclusion
To fix Node.js can’t create Blobs with JavaScript, we can import it from the node:buffer module since Node 16.