lsp-javascript tsserver couldn't find npm

我开启lsp-javascript的时候,发现tsserver找不到npm,然而它提示的npm的位置和我的环境变量设置的不一致。求教何如解决。

emacs-mac的报错

[tsserver] /bin/sh: /usr/local/Cellar/node/9.11.1/bin/npm: No such file or directory

emacs ansi-term下的npm的path

➜ which -a npm
/usr/local/opt/[email protected]/bin/npm
/usr/local/bin/npm
/usr/local/bin/npm
/usr/local/opt/n[email protected]/bin/npm

我的lsp-javascript的配置:

(defconst ztlevi-programming-packages
  '(
    lsp-javascript-typescript
    (lsp-javascript-flow :location built-in)
    (lsp-typescript :location built-in)
  )
)

(defun ztlevi-programming/init-lsp-javascript-typescript ()
  (use-package lsp-javascript-typescript
    :commands lsp-javascript-typescript-enable
    :init
    ;; fix lsp-javascript company prefix
    ;; https://github.com/emacs-lsp/lsp-javascript/issues/9#issuecomment-379515379
    (defun my-company-transformer (candidates)
      (let ((completion-ignore-case t))
        (all-completions (company-grab-symbol) candidates)))
    (defun my-js-hook nil
      (make-local-variable 'company-transformers)
      (push 'my-company-transformer company-transformers))
    (add-hook 'js-mode-hook 'my-js-hook)

    (add-hook 'js-mode-hook #'lsp-javascript-typescript-enable)
    (add-hook 'typescript-mode-hook #'lsp-javascript-typescript-enable) ;; for typescript support
    (add-hook 'js3-mode-hook #'lsp-javascript-typescript-enable) ;; for js3-mode support
    (add-hook 'rjsx-mode #'lsp-javascript-typescript-enable) ;; for rjsx-mode support
    :defer t))

(defun ztlevi-programming/init-lsp-javascript-flow ()
  (use-package lsp-javascript-flow
    :commands lsp-javascript-flow-enable
    :init
    (add-hook 'js-mode-hook #'lsp-javascript-flow-enable)
    (add-hook 'js2-mode-hook #'lsp-javascript-flow-enable) ;; for js2-mode support
    (add-hook 'rjsx-mode #'lsp-javascript-flow-enable) ;; for rjsx-mode support
    :defer t))

(defun ztlevi-programming/init-lsp-typescript ()
  (use-package lsp-typescript
    :commands lsp-typescript-enable
    :init
    (add-hook 'js-mode-hook #'lsp-typescript-enable)
    (add-hook 'js2-mode-hook #'lsp-typescript-enable) ;; for js2-mode support
    (add-hook 'rjsx-mode #'lsp-typescript-enable) ;; for rjsx-mode support
    :defer t))

感觉是你机子上有8.x 9.x两个node(话说node都到9.x了?),主力是8.x,9.x的坏了,然后lang server不知道为什么用了9.x那个,而它的npm坏了……

我是拿brew 装的[email protected],估计有冲突,我全部卸了然后老老实实拿installer装了,现在好了。