ESLint-Formatter icon indicating copy to clipboard operation
ESLint-Formatter copied to clipboard

macOS node error from eslint

Open Michael-Stanford opened this issue 7 years ago • 5 comments

Probably user error, but I installed ESLint-Formatter with Sublime Package Control and still get an odd error when I press cmd-shift-H:

When I type

$ eslint filename.js --fix 

at the bash prompt it works OK.

But when I run eslint-formatter in Sublime Text 3 it pops up a Sublime-logoed window saying:

Error: 
/Users/michael/.nvm/versions/node/v6.4.0/lib/node_modules/eslint/bin/eslint.js:16
const useStdIn = (process.argv.indexOf("--stdin") > -1),
^^^^^
SyntaxError: Use of const in strict mode.
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Michael-Stanford avatar Oct 20 '16 15:10 Michael-Stanford

Very interesting. This shouldn't be an issue with node 6, which from your file path looks like the version running.

Can you confirm that by manually editing

/Users/michael/.nvm/versions/node/v6.4.0/lib/node_modules/eslint/bin/eslint.js

and replacing the whole file with:

throw new Error('Node version: ' + process.version)

I'm curious if somehow the version of node running isn't actually node6 but is using files from that folder.

TheSavior avatar Oct 20 '16 17:10 TheSavior

Wow! You nailed it!!!

Error: /Users/michael/.nvm/versions/node/v6.4.0/lib/node_modules/ eslint/bin/eslint.js:2 throw new Error('Node version: ' + process.version) ^ Error: Node version: v0.10.33 at Object. (/Users/michael/.nvm/versions/ node/v6.4.0/lib/node_modules/eslint/bin/eslint.js:2:7) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3

I am running n (https://github.com/tj/n) to manage my Node versions. I had an old version of node in /usr/local/bin, which was not showing up with

$ which node /Users/michael/.nvm/versions/node/v6.4.0/bin/node

But now that I have deleted it, ESLint Formatter can't find Node at all:

Couldn't find Node.js. Make sure it's in your $PATH by running node -v in your command-line.

$ node -v v6.4.0

It looks as though n works by putting the right path at the beginning of the $PATH environment variable: $echo $PATH /Users/michael/.nvm/versions/node/v6.4.0/bin:...

So it is in my $PATH, but still not being found by ESLint-Formatter

So I put an alias in /usr/local/bin, and now everything is working. Please let me know if you are able to fix it so it really uses the $PATH so I can get rid of the alias.

By the way - it may be related - it also wasn't finding the .eslintrc.js file in the ancestor-path of the file being edited, so I had to hard-wire a "config_path" in the sublime-settings file.

Best regards - thank you so much for your help, and thanks also for giving your excellent code to the community.

Michael.

On Thu, Oct 20, 2016 at 12:28 PM, Eli White [email protected] wrote:

Very interesting. This shouldn't be an issue with node 6, which from your file path looks like the version running.

Can you confirm that by manually editing

/Users/michael/.nvm/versions/node/v6.4.0/lib/node_modules/eslint/bin/eslint.js

and replacing the whole file with:

throw new Error('Node version: ' + process.version)

I'm curious if somehow the version of node running isn't actually node6 but is using files from that folder.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/TheSavior/ESLint-Formatter/issues/26#issuecomment-255172593, or mute the thread https://github.com/notifications/unsubscribe-auth/AB8vVCP9vYygQa5reflWpGKWPScD_Dgzks5q16S2gaJpZM4KcTEC .

Michael Stanford +1 (214) 233-5303

Michael-Stanford avatar Oct 25 '16 18:10 Michael-Stanford

Having the same issue with NVM.

Ideally we shouldn't have to statically specify our eslint path if it is already in our shell's PATH.

❯ which eslint
/Users/timkelty/.nvm/versions/node/v7.4.0/bin/eslint

I don't want to have to change the sublime setting anytime i switch node versions. (this is how https://github.com/roadhump/SublimeLinter-eslint seems to do it)

timkelty avatar Sep 18 '17 15:09 timkelty

I think using which like SublimeLinter does would be a great addition to this plugin. I'd happily accept a PR.

TheSavior avatar Sep 18 '17 22:09 TheSavior

sounds good, I'll put a PR on my todo list!

timkelty avatar Sep 19 '17 12:09 timkelty