SublimeLinter / SublimeLinter-eslint

This linter plugin for SublimeLinter provides an interface to ESLint
MIT License
865 stars 88 forks source link

Error with catch - Unexpected token #301

Closed thedanheller closed 2 years ago

thedanheller commented 4 years ago

I'm using:

"eslint": "7.10.0",
"babel-eslint": "10.1.0"

And SublimeLinter / eslint throws this error:

SublimeLinter: #1 eslint eslint.js ERROR:
=========================================

{PATH_TO_MY_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:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
kaste commented 4 years ago

That usually means that the node you run here and the eslint version do not match.

thedanheller commented 4 years ago

I've tried Node v 10, 11 and 12, no success :/

kaste commented 4 years ago

You probably have a sophisticated setup and environment. Make sure it works on the command line and start Sublime from the Terminal using subl . so it inherits the environment from the Terminal process.

jadamgreen1010 commented 3 years ago

I'm having the exact same issue, and my setup is far from sophisticated. I'm going as bare bones as possible just to get eslint running again (it's been a while).

If I manually fix the optional catch so it looks like } catch (e) { then I get a whole new error:

/Users/{MY_PROJECT_PATH}/node_modules/eslint/lib/eslint/eslint.js:175
    ...unknownOptions
    ^^^

SyntaxError: Unexpected token ...
    at NativeCompileCache._moduleCompile (/Users/{MY_PROJECT_PATH}/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/Users/{MY_PROJECT_PATH}/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (/Users/{MY_PROJECT_PATH}/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/{MY_PROJECT_PATH}/node_modules/eslint/lib/eslint/index.js:3:20)
    at Module._compile (/Users/{MY_PROJECT_PATH}/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)

I'd appreciate any help!

jadamgreen1010 commented 3 years ago

SOLVED

For me, the issue was sublime pathing to an old version of node. I had to reinstall/update NVM.

If anyone else has this issue, I just threw a console.log('node version', process.version) toward the beginning of the .../eslint/bin/eslint.js script. That helped me see that sublime's node version was bad. I'm sure there's a better way to check.

kaste commented 2 years ago

Closing as it old anyway but also has been discussed upstream at the eslint repo.