Nvim-lspconfig: [tsserver] tsserver works standalone, but not in project

Created on 23 Feb 2020  路  5Comments  路  Source: neovim/nvim-lspconfig

neovim version

ff1730373

nvim --version

NVIM v0.5.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/builddir/build/BUILD/neovim-0.4.3.0.git.13599.ff1730373/build/config -I/builddir/build/BUILD/neovim-0.4.3.0.git.13599.ff1730373/src -I/usr/include -I/usr/include/lua-5.1 -I/builddir/build/BUILD/neovim-0.4.3.0.git.13599.ff1730373/build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.4.3.0.git.13599.ff1730373/build/include
Compiled by mockbuild

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
````

</details></td></tr><tr><th>nvim-lsp version</th><td>

[be0f715](https://github.com/neovim/nvim-lsp/tree/be0f71585eb3185b214c84c643e43e9647ef67d1)

</td></tr><tr><th>language server</th><td>

tsserver

</td></tr><tr><th>operating system</th><td>

Fedora 31

</td></tr><tr><th>terminal</th><td>

tmux-2.9a in kitty-0.16.0

</td></tr><tr><th>$TERM</th><td>

tmux-256color

</td></tr></table>

### How to reproduce the problem from neovim startup

<details><summary>.vimrc.minimal</summary>

set runtimepath+=~/.vim,~/.vim/after

call plug#begin('~/.vim/plugged')
Plug '/home/aron/src/nvim-lsp'
call plug#end()

lua < require'nvim_lsp'.tsserver.setup{}
EOF

set omnifunc=v:lua.vim.lsp.omnifunc


</details>

This works:

$ touch foo.js
$ nvim -u ~/.vimrc.minimal foo.js


But this doesn't work:

$ mkdir foo
$ cd foo
$ npm init -y
$ touch index.js
$ nvim -u ~/.vimrc.minimal index.js


It fails with this message (wrapped for reading):

Error executing vim.schedule lua callback:
/usr/share/nvim/runtime/lua/vim/lsp.lua:484:
RPC InternalError message =
"Request initialize failed with message: Couldn't find 'tsserver' executable or 'tsserver.js' module"
```

bug

Most helpful comment

Wanted to add for posterity that I had the same issue today. I just needed to do a global install of typescript to get it working. npm install --global typescript

All 5 comments

Will you install typescript? IIRC, typescript language server is tsserver wrapper.

That did it, thanks!

My projects are JS not TS at the moment, so I hadn't installed typescript in them. But the typescript language server is used for both.

To be clear, this works:

$ mkdir foo
$ cd foo
$ npm init -y
$ npm i typescript   # added
$ touch index.js
$ nvim -u ~/.vimrc.minimal index.js

@agriffis Could I close this issue?

Wanted to add for posterity that I had the same issue today. I just needed to do a global install of typescript to get it working. npm install --global typescript

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesGreenaway picture JamesGreenaway  路  9Comments

justinmk picture justinmk  路  8Comments

glacambre picture glacambre  路  5Comments

jacksonludwig picture jacksonludwig  路  3Comments

nhooyr picture nhooyr  路  3Comments