Flycheck: javascript-jshint won't run, reports: "node: No such file or directory"

Created on 19 Jul 2014  路  10Comments  路  Source: flycheck/flycheck

Tested in both js-mode or js2-mode鈥攖his error pops up constantly:

Checker javascript-jshint returned non-zero exit code 127, but no errors from output: env: node: No such file or directory

Checker definition probably flawed.

Version: Flycheck 0.20alpha (package: 20140718.231)
Emacs: 24.3 on OSX 10.9.4

It sounds like a PATH problem, but my bashrc, zshrc and exec-path includes /usr/local/bin (where homebrew installed node and jshint). I've tested that node is reachable in each shell and to /usr/bin/env, but flycheck still thinks node doesn't exist. Other modes have no problems (tested python, ruby, elisp and xml), and running M-x shell-command RET node --version from within Emacs yields v0.10.29 as expected.

js2-mode's built-in jshint works fine too (or is it jslint? I'm not sure)

_However_, symlinking node into /usr/bin fixes it, indicating it certainly is a PATH issue.

Forgive my ignorance, I'm new to emacs, but is there something obvious I'm missing? Is this being caused inside or outside of emacs (maybe another shell function that doesn't invoke the login shell)?

All 10 comments

The output of M-: (executable-find "node"), and of M-: (process-lines "node" "--version")?

And of M-: (process-lines "which" "node")?

(executable-find "node") #=> "/usr/local/bin/node"
(process-lines "node" "--version") #=> ("v0.10.29")
(process-lines "which" "node") #=> which exited with status 1

@hlissner That is strange. What does M-: (process-lines "env") return?

("TERM=dumb" 
# ... (omitted for brevity)
"USER=hlissner" "HOME=/Users/hlissner" "SHELL=/bin/zsh"
"TMPDIR=/var/folders/s4/s3dz3bz14q58fgghxkfrfr5w0000gn/T/"
"PATH=/usr/bin:/bin:/usr/sbin:/sbin")

There's the errant PATH. Odd though, because I have all the extra rcfiles to satisfy a non-interactive shell (bashrc, bash_profile, zshenv, and zshrc), and I've tried tampering with /etc/{zshenv,bashrc}, but that PATH simply won't change within Emacs.

How did you setup your exec-path? Did you _explicitly_ add /use/local/bin to it?

I'd recommend you to setup $PATH and other variables in your shell, and then use the exec-path-from-shell Emacs package to copy these variables to Emacs. That should fix all your PATH issues on OSX.

How did you setup your exec-path? Did you explicitly add /use/local/bin to it?

Quite explicitly, at the top of my .emacs.d/init.el: (setq exec-path (append '("/usr/local/bin") exec-path))

A C-h v exec-path yielded: ("/usr/local/bin" "/usr/bin" "/bin" "/usr/sbin" "/sbin" ...)

exec-path-from-shell

Huh, I installed and ran it and it seems to have fixed all my problems. Problem solved!

Thanks so much for your help! :D

I found in my OSX, exec-path already include "/usr/local/bin", but it doesnot work, and need following setenv as described by http://stackoverflow.com/questions/18102833/could-not-start-tern-server-in-emacs
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))

We generally recommend exec-path-from-shell for this purpose.

@lunaryorn exec-path-from-shell best solution, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

futile picture futile  路  8Comments

mrlee23 picture mrlee23  路  5Comments

yuyang0 picture yuyang0  路  7Comments

jwintz picture jwintz  路  9Comments

itkach picture itkach  路  3Comments