midi-json-parser icon indicating copy to clipboard operation
midi-json-parser copied to clipboard

Error importing module in node.js

Open infojunkie opened this issue 3 years ago • 2 comments
trafficstars

Trying to import the module in node.js v17.4.0, I get the following error:

    ReferenceError: Blob is not defined

      at node_modules/midi-json-parser/build/es5/bundle.js:10:13
      at node_modules/midi-json-parser/build/es5/bundle.js:2:65
      at Object.<anonymous> (node_modules/midi-json-parser/build/es5/bundle.js:5:3)

Looks like node.js needs additional work to import Blob as per https://stackoverflow.com/questions/14653349/node-js-cant-create-blobs

infojunkie avatar Apr 07 '22 13:04 infojunkie

I'm sorry, but that's expected. The module is meant to only work in the browser. It's because it uses a Web Worker internally for the parsing. We could certainly build a version for Node.js as well. It just didn't happen so far. I guess it should then work with streams instead of an ArrayBuffer.

chrisguttandin avatar Apr 08 '22 07:04 chrisguttandin

Yes, thanks for considering a node version.

infojunkie avatar Apr 08 '22 14:04 infojunkie