tern icon indicating copy to clipboard operation
tern copied to clipboard

Can not start tern server in emacs which is installed in cygwin

Open ouchuan opened this issue 7 years ago • 0 comments
trafficstars

If you use emacs in CYGWIN and nodejs installed by WIN installer, when you use tern, you'll receive a message like this: Request failed: Could not start Tern server module.js:559 throw err; ^ Error: Cannot find module 'C:\cygdrive\C\Users***\AppData\Roaming\npm\node_modules\tern\bin\tern' at Function.Module._resolveFilename (module.js:557:15) at Function.Module._load (module.js:484:25) at Function.Module.runMain (module.js:703:10) at startup (bootstrap_node.js:193:16) at bootstrap_node.js:660:3

Because in cygwin, if you use full name to start a nodejs script, nodejs will add prefix "C:" to the argument

Temporary Solution:

(defvar tern-command
(let* ((script-file (or load-file-name
                          (and (boundp 'bytecomp-filename) bytecomp-filename)
                          buffer-file-name))
         (bin-file (expand-file-name "../bin/tern" (file-name-directory (file-truename script-file)))))
    (if (file-exists-p bin-file)
        (if (eq system-type 'windows-nt) (list "node" bin-file)
	  (if (eq system-type 'cygwin) (list "tern")    ★★★★★★★★★★★When using cygwin, make tern-command be "tern"★★★★★★★★★★★
	      (list bin-file)))
      (list "tern")))

ouchuan avatar Jun 13 '18 05:06 ouchuan