Streams, Pipe and Sox transcoding mess

Hey there,

Disclaimer: Please note this is the first time I am using Streams and Pipes, so it may not be Sox related.

I am trying to implement on-the-fly transcoding using Sox in NodeJS, but the code is crashing with:

Error: spawn sox ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19) at onErrorNT (internal/child_process.js:469:16) at processTicksAndRejections (internal/process/task_queues.js:84:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn sox', path: 'sox', spawnargs: [ '/tmp/981152e3-6091-4a32-a7e6-81f1b9157b90', '--type', 'flac', '-' ] }

The issue can be run directly from here :

For your convenience, here is the code:

var sox = require('sox-stream'); //
var stream = require("stream");

function TranscodeAudioFromURL(url, callback) {
    var request = require('request');
    return new Promise((resolve, reject) => {
            url: url,
            encoding: null
        }, function(err, res, body) {
            if (!err && res.statusCode == 200) {
                const src = new stream.Readable(); // Stream for input
                const dest = new stream.Writable(); // Stream for output
                src.push(body); //push of the input audio file to the stream  
                src.push(null); // ending the stream
                src // Piping the output stream to the transcoder
                        output: {
                            type: 'flac'
                return resolve(dest); // return converted audio file as stream
            } else


// Calling the transcoder
TranscodeAudioFromURL('').then((outputStream) => {
    // "Success!"
    console.log("Transcoded binary"+JSON.stringify(outputStream))
}, reason => {
    // failure

Am I missing something?