grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
357 stars 52 forks source link

canot found module 'fs' #9

Closed plh97 closed 6 years ago

grimmdude commented 6 years ago

Hi @pengliheng,

Thanks for your message. Could you please show an example of the code you're using which generates this error? The only function in this player which uses the fs module is Player.loadFile(). Are you using this in node or browser? Thanks,

-Garrett

allan-farrell commented 6 years ago

I'm trying to build your player for the browser using Webpack. I'm seeing the same thing. The error is:

ERROR in ./~/midi-player-js/module/index.js Module not found: Error: Can't resolve 'fs' in path.......

My code is simple - it doesn't do anything yet only require packages. See below:

var PlayMidi = (function() {
  var Soundfont = require('soundfont-player')
  var MidiPlayer = require('midi-player-js');
  var loadFile, loadDataUri, Player;
  var AudioContext = window.AudioContext || window.webkitAudioContext || false; 
  var ac = new AudioContext || new webkitAudioContext;
})();

module.exports = PlayMidi;

Hope that helps!

grimmdude commented 6 years ago

Hi @allan-farrell,

Thanks for your message. I see what's going on, will work on a solution for this. In the meantime can you try this fix and let me know if it helps?

https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285598881

-Garrett

allan-farrell commented 6 years ago

LoL! I just discovered that fix myself about 5 min ago - it does work!

Great lib, by the way.

Thanks.

grimmdude commented 6 years ago

Awesome! Thx