Nvim-lspconfig: tsserver logs errors that it can't find npm

Created on 14 May 2020  路  4Comments  路  Source: neovim/nvim-lspconfig

I was initially debugging something else in the project tsconfig.json & found this by luck.

  • nvim --version:
NVIM v0.5.0-nightly-78-g02155f5c1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200514-40210-1qsrhzq/build/config -I/tmp/neovim-20200514-40210-1qsrhzq/src -I/usr/local/include -I/tmp/neovim-20200514-40210-1qsrhzq/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200514-40210-1qsrhzq/build/src/nvim/auto -I/tmp/neovim-20200514-40210-1qsrhzq/build/include

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-02155f5/share/nvim"

Run :checkhealth for more info

health#vimtex#check
========================================================================
## vimtex
  - OK: Vim version should have full support!
  - WARNING: bibtex is not executable, so bibtex completions are disabled.
  - OK: General viewer should work properly!
  - ERROR: |g:vimtex_compiler_method| (`latexmk`) is not executable!

health#targets#check
========================================================================
  - OK: No conflicting mappings found

health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: sumneko_lua: configuration checked.
  - INFO: ocamlls: configuration checked.
  - INFO: yamlls: configuration checked.
  - ERROR: pyls: The given command "pyls" is not executable.
  - INFO: cssls: configuration checked.
  - INFO: rls: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: jsonls: configuration checked.
  - INFO: tsserver: configuration checked.
  - INFO: bashls: configuration checked.

health#gitmessenger#check
========================================================================
  - OK: +job is available to execute Git command
  - OK: Git command `git` is available: git version 2.26.2
  - OK: Floating window is available for popup window

health#completion_nvim#check
========================================================================
## general
  - OK: neovim version is supported

## completion source
  - OK: all completion source are valid

## snippet source
  - OK: You are using UltiSnips as your snippet source

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='tmux'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0ms
  - INFO: $TERM: tmux-256color

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 2 provider (optional)
  - INFO: Using: g:python_host_prog = "/usr/bin/python2"
  - INFO: Executable: /usr/bin/python2
  - ERROR: Command error (job=5, exit code 1): `'/usr/bin/python2' -c 'import sys; sys.path = list(filter(lambda x: x != "", sys.path)); import neovim; print(neovim.__file__)'` (in '/Users/ahmedelgabri/Sites/work/miro/client')
    stderr: Traceback (most recent call last):  File "<string>", line 1, in <module>ImportError: No module named neovim
  - INFO: Python version: 2.7.16
  - INFO: pynvim version: unable to load neovim Python module
  - ERROR: pynvim is not installed.
    Error: unable to load neovim Python module
    - ADVICE:
      - Run in shell: pip install pynvim

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/local/bin/python3"
  - INFO: Executable: /usr/local/bin/python3
  - INFO: Python version: 3.7.7
  - INFO: pynvim version: 0.4.1
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Disabled (g:loaded_ruby_provider=0).

## Node.js provider (optional)
  - INFO: Node.js: v14.2.0
  - INFO: Nvim node.js host: /usr/local/bin/neovim-node-host
  - OK: Latest "neovim" npm/yarn package is installed: 4.8.0

## Perl provider (optional)
  - INFO: Disabled (g:loaded_perl_provider=0).
  • What language server(If the problem is related to a specific language server): tsserver
  • Operating system/version: macOS 10.15.4
  • Terminal name/version: kitty 0.17.3
  • $TERM: tmux-256color

How to reproduce the problem from neovim startup

I have node installed throw homebrew so npm is in /usr/local/bin/npm

  1. open a TypeScript foo.ts or JavaScript file foo.js
  2. Check ~/.local/share/nvim/vim-lsp.log
[ ERROR ] 2020-05-14T10:40:31Z+0200 ] ...EAD-02155f5/share/nvim/runtime/lua/vim/lsp/callbacks.lua:175 ] "[tsserver] /bin/sh: /usr/local/Cellar/node/14.2.0/bin/npm: No such file or directory\n"

[ ERROR ] 2020-05-14T10:41:00Z+0200 ] ...EAD-02155f5/share/nvim/runtime/lua/vim/lsp/callbacks.lua:175 ] "[tsserver] /bin/sh: /usr/local/Cellar/node/14.2.0/bin/npm: No such file or directory\n"

Actual behaviour

Logs errors that it can't find npm

Expected behaviour

To find the correct npm path & not to error out

bug

Most helpful comment

This is a known issue with tsserver/npm/node/homebrew, not with nvim-lsp. See https://github.com/microsoft/TypeScript/issues/23924 for reference, there's probably many like it if you search for 'tsserver npm: No such file or directory'.

Anyway, the quick solution for you is this:

$ ln -s /usr/local/bin/npm /usr/local/Cellar/node/14.2.0/bin/npm

All 4 comments

This is a known issue with tsserver/npm/node/homebrew, not with nvim-lsp. See https://github.com/microsoft/TypeScript/issues/23924 for reference, there's probably many like it if you search for 'tsserver npm: No such file or directory'.

Anyway, the quick solution for you is this:

$ ln -s /usr/local/bin/npm /usr/local/Cellar/node/14.2.0/bin/npm

Also, this breaks every time Node is updated or re-installed.

This is a known issue with tsserver/npm/node/homebrew, not with nvim-lsp. See microsoft/TypeScript#23924 for reference, there's probably many like it if you search for 'tsserver npm: No such file or directory'.

Anyway, the quick solution for you is this:

$ ln -s /usr/local/bin/npm /usr/local/Cellar/node/14.2.0/bin/npm

I was already thinking about that but wanted to check first.

Also, this breaks every time Node is updated or re-installed.

Exactly, but since it's not a nvim-lsp issue will close this issue & deal with this on my own then.

Thanks

Sorry, but I didn't want to open a new issue. It seems that the tsserver LSP is resolving package.json before tsconfig.json

https://github.com/neovim/nvim-lsp/blob/b77a24f6b6bdf32d621f37c733f399f33a7eab0d/lua/nvim_lsp/tsserver.lua#L20

But even if I change that to be

nvim_lsp.tsserver.setup{
  root_dir = nvim_lsp.util.root_pattern("tsconfig.json", "package.json", ".git");
}

It still resolves package.json before tsconfig.json I looked at https://github.com/neovim/nvim-lsp/blob/b77a24f6b6bdf32d621f37c733f399f33a7eab0d/lua/nvim_lsp/util.lua#L289-L322 but my Lua knowledge is very minimal. I tried to add a couple of print statements but couldn't figure out the issue.

The only solution for me now is to remove package.json from the list.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlukes picture dlukes  路  4Comments

nomasprime picture nomasprime  路  5Comments

cideM picture cideM  路  6Comments

agriffis picture agriffis  路  5Comments

jacksonludwig picture jacksonludwig  路  11Comments