TooTallNate / node-lame

Node.js native bindings to libmp3lame & libmpg123
MIT License
567 stars 113 forks source link

Cannot read property 'on' of undefined #100

Open nissenyeh opened 4 years ago

nissenyeh commented 4 years ago

here is my code

  const fileName = req.files.voice.name
  const originFilePath = './upload/' + fileName + '.mp3'
  const encodeFilePath = './upload/after-' + fileName + '.mp3'

  console.log(req.files.voice.name, req.files.voice.size);

  req.files.voice.mv(originFilePath,function(err){ 
    if(err)console.log(err)
    const encoder = new Lame({ output: encodeFilePath }).setFile(originFilePath); 
    encoder.decode()
    .then(() => {
     ...
  })

1|app | TypeError: Cannot read property 'on' of undefined 1|app | at Lame.execProgress (/srv/voice-diagnosis-formal/node_modules/node-lame/lib/build/Lame.js:272:25) 1|app | at Lame.progress (/srv/voice-diagnosis-formal/node_modules/node-lame/lib/build/Lame.js:145:25) 1|app | at Lame.decode (/srv/voice-diagnosis-formal/node_modules/node-lame/lib/build/Lame.js:107:21) 1|app | at /srv/voice-diagnosis-formal/routes/voice.js:27:13 1|app | at err (/srv/voice-diagnosis-formal/node_modules/express-fileupload/lib/utilities.js:57:57) 1|app | at WriteStream.fstream.on (/srv/voice-diagnosis-formal/node_modules/express-fileupload/lib/utilities.js:186:29) 1|app | at WriteStream.emit (events.js:182:13) 1|app | at lazyFs.close (internal/fs/streams.js:208:14) 1|app | at FSReqWrap.oncomplete (fs.js:141:20)

And the error happened because instance.stdout is undefined. but why