nolanlawson/blob-util

TypeError: Blob is not a constructor when using in nodejs

josephrocca opened this issue ยท 2 comments

I tried to use this in nodejs and on line 93 of index.js I'm getting TypeError: Blob is not a constructor.

image

Given that quite a few people seem to be using this, I was surprised and thought it might be something I was doing wrong. I cut it down to this minimal example, and I still get the error (coming from blobUtil.createBlob):

let blobUtil = require('blob-util');
let myString = "blah blah";
let myBlob = blobUtil.createBlob([myString]);
let myUrl = blobUtil.createObjectURL(myBlob, { type: 'application/javascript; charset=utf-8' });
console.log(myUrl);

+1, although I had it originally working . I am using it in a react-native project.

Blobs are a browser feature and are not supported in NodeJS or react-native: https://developer.mozilla.org/en-US/docs/Web/API/Blob