nolanlawson / blob-util

Cross-browser utils for working with binary Blobs
https://nolanlawson.github.io/blob-util
Apache License 2.0
503 stars 45 forks source link

TypeError: Blob is not a constructor when using in nodejs #27

Closed josephrocca closed 7 years ago

josephrocca commented 7 years ago

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);
eapostol commented 7 years ago

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

nolanlawson commented 7 years ago

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