javascriptnode.jsdiscord.jsytdl

SyntaxError: Missing catch or finally after try with ytdl-core


My code was working a few days ago. I haven't changed anything and now get this error. I have no idea where to even begin or where it's coming from.

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) {
 
}

Solution

  • You could downgrade your ytdl-core package to version ^4.9.1 or ^4.10.0 and that should fix this:

    npm i ytdl-core@4.9.1
    

    If you don't want to downgrade...

    As far as I know, there is a PR to fix this bug, so the next minor version should work as expected.

    In the meantime, you could update your node_modules/ytdl-core/lib/utils.js file (although I don't usually recommend this). On line 63 replace /(^|[[{:;,])\s?$/ with /(^|[[{:;,/])\s?$/:

    const ESCAPING_SEQUENZES = [
      // Strings
      { start: '"', end: '"' },
      { start: "'", end: "'" },
      { start: '`', end: '`' },
      // RegeEx
      { start: '/', end: '/', startPrefix: /(^|[[{:;,/])\s?$/ },
    ];
    

    Update

    v4.11.4 has been released that includes the fix, so updating to this (or the latest) release will fix this:

    npm i ytdl-core@4.11.4