przemyslawpluta / node-youtube-dl

youtube-dl driver for node
MIT License
1.71k stars 368 forks source link

UnhandledPromiseRejectionWarning #327

Open ultrasamad opened 4 years ago

ultrasamad commented 4 years ago

I try running a basic example on this repo and I'm getting UnhandledPromiseRejectionWarning. youtube-dl version: 3.0.2

This is my code:

const fs = require('fs')
const youtubedl = require('youtube-dl')

const url = 'https://www.youtube.com/watch?v=LXb3EKWsInQ'
const options = ['--format=18']
const outputFile = 'wildlife-4k.mp4'

const video = youtubedl(url, options, { cwd: __dirname })
video.on('info', function(info) {
  console.log('Download started')
  console.log('filename: ' + info._filename)
  console.log('size: ' + info.size)
})

video.pipe(fs.createWriteStream(outputFile))

and this is the error:

 UnhandledPromiseRejectionWarning: Error: Command failed with exit code 3221225781: C:\Users\Ibrahim\Desktop\Downloader\node_modules\youtube-dl\bin\youtube-dl.exe --dump-json --format=18 --encoding utf8 http://www.youtube.com/watch?v=LXb3EKWsInQ
    at makeError (C:\Users\$USER\Desktop\Downloader\node_modules\execa\lib\error.js:56:11)
    at handlePromise (C:\Users\$USER\Desktop\Downloader\node_modules\execa\index.js:114:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:17392) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:17392) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
bighitbiker3 commented 4 years ago

Use the master branch npm i https://github.com/przemyslawpluta/node-youtube-dl.git