title: Uncaught (in promise) TypeError: spawn is not a function
body: <p>I am bit stuck here. I am submitting an async request with redux-thunk in my action creator which looks like this:</p>
  
  <pre><code>export const downloadFromYoutube = (download) =&gt; {
    console.log("Hello");
      return dispatch =&gt; {
        var YoutubeMp3Downloader = require('youtube-mp3-downloader');
  
        var YD = new YoutubeMp3Downloader({
            "ffmpegPath": "/usr/local/Cellar/ffmpeg/3.2.2/bin/ffmpeg",        // Where is the FFmpeg binary located?
            "outputPath": "/Users/dominik/Coding/youtube-downloader-papa/downloads",    // Where should the downloaded and encoded files be stored?
            "youtubeVideoQuality": "highest",       // What video quality should be used?
            "queueParallelism": 2,                  // How many parallel downloads/encodes should be started?
            "progressTimeout": 2000                 // How long should be the interval of the progress reports
        });
  
        console.log("Hello");
        YD.on("finished", data =&gt; dispatch({ type: "FINISHED", payload: data }));
        YD.on("error", error =&gt; dispatch({ type: "ERROR", payload: error }));
        YD.on("progress", progress =&gt; dispatch({ type: "PROGRESS", payload: progress }));
  
        // dispatch a "starting" action
        // dispatch({ type: "STARTING" });
  
        // start the download
        YD.download("UDzGLMLhy80");
       }
    };
  </code></pre>
  
  <p>But I am always getting the following error:</p>
  
  <blockquote>
    <p>TypeError: spawn is not a function</p>
  </blockquote>
  
  <p>I am using React/Redux in electron. I also should mention redux-thunk does work when I use a timeout function instead of the download function. However, the code above &amp; use of the youtube downloader library also works fine when I just put it in a plain javascript / nodejs file and execute it, so it seems to have something to do with the way I handle promises in React.</p>
  
  <p>Here is the full error log:</p>
  
  <blockquote>
    <p>Uncaught (in promise) TypeError: spawn is not a function(…)(anonymous
    function) @ processor.js:135proto._getFfmpegPath @
    capabilities.js:90proto._spawnFfmpeg @
    processor.js:115proto.availableFormats.proto.getAvailableFormats @
    capabilities.js:514(anonymous function) @ capabilities.js:564fn @
    async.js:746(anonymous function) @ async.js:1213(anonymous function) @
    async.js:166(anonymous function) @ async.js:706(anonymous function) @
    async.js:167async.waterfall @ async.js:710proto._checkCapabilities @
    capabilities.js:561(anonymous function) @ processor.js:287fn @
    async.js:746(anonymous function) @ async.js:1213(anonymous function) @
    async.js:166(anonymous function) @ async.js:706(anonymous function) @
    async.js:167async.waterfall @ async.js:710proto._prepare @
    processor.js:284proto.exec.proto.execute.proto.run @
    processor.js:420proto.saveToFile.proto.save @ recipes.js:28(anonymous
    function) @ YoutubeMp3Downloader.js:151emitOne @ events.js:77emit @
    events.js:169(anonymous function) @ index.js:113emitOne @
    events.js:77emit @ events.js:169ClientRequest._connect @
    request.js:235(anonymous function) @ request.js:128</p>
  </blockquote>