I'm quite new to Vimscript and editing ~/.vimrc, and was tweaking this file after having installed Pathogen and Syntastic to do live syntax checking for JavaScript. However, in my current set-up, I want Syntastic to use the per-project executables for the syntax checking, located within ./node_modules/.bin/ (the command npm bin returns this path). In my search for how to do this, I came across GitHub issues like this, using the following Vimscript variable and assignment (or something like it; there are several instances on that page):

let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'

However, in my attempts to use this construct, it wouldn't "work"; eslint isn't found, and running :SyntasticInfo shows that there are no checkers available for .js and .jsx files. However, when I adapted this to the following...

let g:syntastic_javascript_eslint_exec = '`npm bin`/eslint'

... it works! Could someone explain to me, this noob, why the first construct doesn't work, what I could be missing here? Really wanting to learn!

  • 2
    The first form doesn't work because you're taking it out of context: syntastic needs an exec (not exe) pointing to a valid eslint executable. The second form works only as long as you don't switch to a different project from within Vim. See the thread you quoted for possible solutions. Or use autocmds. Or use something like ALE instead of syntastic. Either way, syntastic is not the best way to start learning about Vim. – lcd047 Dec 20 '17 at 5:53
  • @lcd047 Thanks so much for this! Yeah, I saw that, but the distinction of _exe and _exec was a bit obtuse to me... and the suggestion of adding the path to any binary as the _exec setting didn't make much sense, nor did it work, as vim complained like so: syntastic: error: checker javascript/eslint: can't parse version string (abnormal termination?) – Paul Sebastian Bruno Dec 21 '17 at 13:02
  • @lcd047 However, I most thank you about your suggestion of ALE! This is great; gonna set it up in an hr. or two! Thanks so much! – Paul Sebastian Bruno Dec 21 '17 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.