You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ytdl-core出现SyntaxError: Missing catch or finally after try错误求助

问题描述

代码几天前还能正常运行,未做任何修改,如今却出现如下错误,完全不清楚问题根源与排查方向:

evalmachine.<anonymous>:25
[])||(0,c[2])((0,c[45])((0,c[25])(c[21],c[55],(0,c[11])()),c[2],(0,c[86])(c[55],c[53]),c[13],c[77],c[27]),c[52],c[62],c[74]),1==c[43]&&((0,c[45])((0,c[2])((0,c[13])(c[65+Math.pow(3,2)
%391],c[85]),c[78],c[35],c[68]),c[2],((0,c[76])(c[3],c[77]),c[40])(c[77]),c[40],c[87]),1)||(((((0,c[13])(c[87],c[65]),c[52])(c[46],c[Math.pow(5,3)%149+-51]),c[47])(c[63],c[1]),c[62])(
c[50],c[18]),c[28])(c[56],c[50])};lma(ncode);


                                ^

SyntaxError: Missing catch or finally after try
    at new Script (node:vm:100:7)
    at exports.decipherFormats (C:\Users\madda\OneDrive\Documents\github\humble-tip-bot\node_modules\ytdl-core\lib\sig.js:116:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async exports.getInfo (C:\Users\madda\OneDrive\Documents\github\humble-tip-bot\node_modules\ytdl-core\lib\info.js:401:17) {
 
}
解决办法

这个错误的核心原因是YouTube更新了视频签名的加密算法,你当前使用的ytdl-core版本过旧,无法适配新的签名解析逻辑,导致动态执行的代码出现语法错误。

具体修复步骤:

  • 卸载现有旧版本ytdl-core:
    npm uninstall ytdl-core
    
  • 安装最新版本:
    npm install ytdl-core@latest
    
  • 如果最新官方版本仍存在问题,可以尝试使用维护活跃的ytdl-core分支版本,或者临时替换为其他兼容的YouTube视频获取库。

这类依赖第三方平台的工具库,很容易因平台接口、加密规则更新而失效,建议日常维护中定期检查依赖包更新,或在项目配置中设置合理的版本兼容范围。

内容的提问来源于stack exchange,提问作者Maddax Lallatin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 15:55:28