Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token - } catch { #13838

Closed
deleonio opened this issue Nov 12, 2020 · 11 comments
Closed

SyntaxError: Unexpected token - } catch { #13838

deleonio opened this issue Nov 12, 2020 · 11 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion needs info Not enough information has been provided to triage this issue triage An ESLint team member will look at this issue soon

Comments

@deleonio
Copy link

} catch {

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Nov 12, 2020
@yeonjuan yeonjuan added the needs info Not enough information has been provided to triage this issue label Nov 12, 2020
@eslint-deprecated
Copy link

Hi @martinoppitz, thanks for the issue. It looks like there's not enough information for us to know how to help you.

If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

Requesting a rule change? Please see Proposing a Rule Change for instructions.

If it's something else, please just provide as much additional information as possible. Thanks!

@yeonjuan
Copy link
Member

Hi :) @martinoppitz
What node version did you use? ESLint is supporting node version "^10.12.0 || >=12.0.0". Please check your node version.

@nguyenj
Copy link

nguyenj commented Nov 12, 2020

I'm also getting this error. Here's what I have:

bash output:

$ npm run lint
> eslint . --ext .js

/Users/user/code/project/node_modules/eslint/bin/eslint.js:93
        } catch {
                ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm log:

info it worked if it ends with ok
verbose cli [ '/Users/john/n/bin/node', '/usr/local/bin/npm', 'run', 'lint' ]
info using npm@6.14.8
info using node@v12.13.0
verbose run-script [ 'prelint', 'lint', 'postlint' ]
verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
verbose stack     at EventEmitter.emit (events.js:210:5)
verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
verbose stack     at ChildProcess.emit (events.js:210:5)
verbose stack     at maybeClose (internal/child_process.js:1021:16)
verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
verbose Darwin 19.6.0
verbose argv "/Users/john/n/bin/node" "/usr/local/bin/npm" "run" "lint"
verbose node v12.13.0
verbose npm  v6.14.8

package.json:

{
  "scripts": {
    "lint": "eslint . --ext .js"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.7.0",
    "@typescript-eslint/parser": "^4.7.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.13.0",
    "eslint-config-prettier": "^6.7.0",
    "eslint-config-react-app": "^5.2.1",
    "eslint-loader": "^3.0.2",
    "eslint-plugin-flowtype": "^5.2.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jest": "^24.1.3",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.21.5",
    "eslint-plugin-react-hooks": "^4.2.0",
  }
}

@btmills
Copy link
Member

btmills commented Nov 15, 2020

Thanks for the additional info @nguyenj. Node 12.13.0 should support optional catch bindings, so I'm not sure what's going on. I tried to reproduce the exception by running ESLint on Node 12.13.0, but everything worked normally. Does the exception reproduce if you run ESLint in a test project without any plugins? I wouldn't think that should matter, but at least it removes some variables. If it does, pushing it up as an example repository that we could clone and run would help.

@nguyenj
Copy link

nguyenj commented Nov 24, 2020

@btmills I found the issue, a dependency package was causing an issue. Thank you for responding!

@btmills
Copy link
Member

btmills commented Nov 24, 2020

Glad you figured it out @nguyenj. @martinoppitz do you have any more info here?

@btmills
Copy link
Member

btmills commented Nov 30, 2020

Closing for now since at least one case has been resolved and we have no information on the original. @martinoppitz if you have more information for us we'd be happy to take a look!

@btmills btmills closed this as completed Nov 30, 2020
@prototypicalpro
Copy link

prototypicalpro commented Dec 4, 2020

Hello @btmills! I was able to reproduce this issue using the latest version of ESLint (v7.14.0) on the demo page. As a result, I think this issue should be reopened (I can also open a new issue if that would be preferred).

@btmills
Copy link
Member

btmills commented Dec 4, 2020

Hi @prototypicalpro, optional catch binding is an ES2019 feature. Your demo link was using ecmaVersion: 5. If you set ecmaVersion: 2019, it works fine.

@jadamgreen1010
Copy link

I also had this issue using SublimeLinter-eslint. I included my finding here SublimeLinter/SublimeLinter-eslint#301

tl;dr sublime may be mapping to the wrong node version, try reinstalling nvm

@fjaxyu
Copy link

fjaxyu commented Jan 25, 2021

This same issue occurred for me when I updated and started using a new nvm node version. Quitting terminal and re-opening stopped the error from occurring anymore, I didn't need to re-install nvm though.

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators May 30, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion needs info Not enough information has been provided to triage this issue triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

7 participants