question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't install or run due to the “catch” throws a Syntax Error

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 8.0.0
  • Platform / OS version: win7 and win10
  • URLs (if applicable):
  • Node.js version: 9.4.0

What steps will reproduce the problem? when i install or use node xxx.js to run a js file

Please include code that reproduces the issue.

1.npm i puppeteer 2.node xxx.js

What is the expected result? i think the catch`s Syntax is ‘catch(err) {}’ not ‘catch{}’

What happens instead? npm i puppeteer result: (node:9820) UnhandledPromiseRejectionWarning: …\node_modules\puppeteer\lib\cjs\puppeteer\node\install.js:139 catch { ^ SyntaxError: Unexpected token { at new Script (vm.js:51:7) at createScript (vm.js:138:10) at Object.runInThisContext (vm.js:199:10) at Module._compile (module.js:624:28) at Object.Module._extensions…js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) at Module.require (module.js:604:17) at require (internal/module.js:11:18)

node xxx.js result: node xxx.js …\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:712 catch { ^

SyntaxError: Unexpected token { at new Script (vm.js:51:7) at createScript (vm.js:138:10) at Object.runInThisContext (vm.js:199:10) at Module._compile (module.js:624:28) at Object.Module._extensions…js (module.js:671:10) at Module.load (module.js:573:32) at tryModuleLoad (module.js:513:12) at Function.Module._load (module.js:505:3) at Module.require (module.js:604:17) at require (internal/module.js:11:18)

this is source code:

page.js: L709~L716

    try {
        payload = JSON.parse(event.payload);
    }
    catch {
        // The binding was either called by something in the page or it was
        // called before our wrapper was initialized.
        return;
    }

install.js : L135~L141

                try {
                    const versions = JSON.parse(data);
                    return resolve(versions.FIREFOX_NIGHTLY);
                }
                catch {
                    return reject(new Error('Firefox version not found'));
                }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
lazytingcommented, Oct 28, 2021

Same problem here. Solved by upgrading node to 14

Here’s a solution.

1reaction
MrWebcommented, Mar 25, 2021

Same problem here. Solved by upgrading node to 14

Read more comments on GitHub >

github_iconTop Results From Across the Web

my project java code has some syntax error but it is maven ...
... try { parseConfigFile(file); } catch (Exception e) { logger.error("", e); } } protected abstract void parseConfigFile(File file) throws ...
Read more >
How to Throw Exceptions in Python
Here's an example of Python's “try-except” (often mistakenly referred to as “try-catch-exception”). Let's say we want our code to run only ...
Read more >
Syntax Error - an overview
A syntax error occurs when a programmer writes an invalid statement. ... mistake is to spell a variable name incorrectly; MATLAB will also...
Read more >
TRY...CATCH (Transact-SQL) - SQL Server
Syntax; Arguments; Remarks; Retrieving Error Information; Errors ... CATCH construct cannot span multiple blocks of Transact-SQL statements.
Read more >
SyntaxError: missing ; before statement - JavaScript | MDN
... for...of · function declaration · function* · if...else · import · label · let · return · switch · throw · try...catch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found