Heroku错误:ENOENT:没有这样的文件或目录youtube-dl

时间:2019-07-20 09:23:59

标签: node.js express hosting

所以我试图将我的youtube-dl下载器托管在heroku上,但是由于某些原因,我总是会收到此错误

2019-07-22T16:29:10.640375+00:00 app[web.1]: C:/Users/J/Desktop
2019-07-22T16:29:10.648243+00:00 app[web.1]: events.js:174
2019-07-22T16:29:10.648247+00:00 app[web.1]: throw er; // Unhandled 'error' event
2019-07-22T16:29:10.648249+00:00 app[web.1]: ^
2019-07-22T16:29:10.648251+00:00 app[web.1]:
2019-07-22T16:29:10.648257+00:00 app[web.1]: Error: ENOENT: no such file or directory, open 'C:/Users/J/Desktop/2pac - Starin' Through My Rear View (Music Video).mp4'
2019-07-22T16:29:10.648259+00:00 app[web.1]: Emitted 'error' event at:
2019-07-22T16:29:10.648263+00:00 app[web.1]: at errorOrDestroy (internal/streams/destroy.js:107:12)
2019-07-22T16:29:10.648265+00:00 app[web.1]: at WriteStream.onerror (_stream_readable.js:717:7)
2019-07-22T16:29:10.648267+00:00 app[web.1]: at WriteStream.emit (events.js:198:13)
2019-07-22T16:29:10.648269+00:00 app[web.1]: at lazyFs.open (internal/fs/streams.js:277:12)
2019-07-22T16:29:10.648271+00:00 app[web.1]: at FSReqWrap.args [as oncomplete] (fs.js:140:20)
2019-07-22T16:29:10.725327+00:00 heroku[web.1]: State changed from up to crashed
2019-07-22T16:29:10.706740+00:00 heroku[web.1]: Process exited with status 1
2019-07-22T16:32:49.299084+00:00 heroku[web.1]: State changed from crashed to starting
2019-07-22T16:32:52.435442+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-07-22T16:32:55.257848+00:00 app[web.1]: i am listeing
2019-07-22T16:32:56.859491+00:00 heroku[web.1]: State changed from starting to up

这是从URL接收参数的代码。我可以接收参数并将其打印在屏幕上。那在工作 但是然后当我想执行下载功能时,出现了上面的错误。

app.get('/:var1:var2:var3' , function (req, res) {
    var var1= req.query.var1;
    var var2= req.query.var2;
    var var3 = req.query.var3;

    if(var1== null) {
      var1 = "test"
    }
    if(var2 == null) {
     var2 = "test"
    }
    if(var3 == null || var3 == '') {
      var3 = "test"
    }

    download(var1,var2,var3)
    res.send();
    //res.send(var1) sends results to browser
});

这是我发送参数的网址

 window.open(' https://example.com/&var1=' + var1 + '&var2='+ var2 + '&var3='+ encodeURIComponent(var3));

download()函数已在本地测试并且正在运行。 Heroku是否不会重新启动下载功能?

(错误代码的)第一行是文件下载后的路径。路径应该是正确的。 如果我将控制台节点index.js放入,则该功能可以正常运行,并且可以下载视频。但是在heroku上,它无法将视频写入用户。

0 个答案:

没有答案