grimmdude / MidiWriterJS

♬ A JavaScript library which provides an API for programmatically generating and creating expressive multi-track MIDI files and JSON.
MIT License
557 stars 60 forks source link

ReferenceError: fs is not defined when using write.saveMIDI() #36

Closed jpw closed 6 years ago

jpw commented 6 years ago

Hi there!

I'm just starting to play around with MidiWriterJS. Many thanks for it, looks cool!

Am running in node not the browser. When I try to write.saveMIDI() I get this error;

.../Projects/midi-maker/node_modules/midi-writer-js/build/index.js:1005
            fs.writeFile(filename + '.mid', buffer, function (err) {
            ^

ReferenceError: fs is not defined

I just changed fs.writeFile(filename to require('fs').writeFile(filename to hack around it for now. I would do a PR but am unfamiliar with Bower, so no idea what's going on in yr source, sorry :)

grimmdude commented 6 years ago

Hi @jpw ,

Thanks for your message. Yea, looks like the same issue as #35. That saveMIDI() method isn't implemented very well, I'm planning on removing it from future releases since it's just a wrapper for fs.writeFile().

Check the last comment in #35 for a better way to save files.

-Garrett

jpw commented 6 years ago

Aha, righto, thanks! :)