Skip to content

Error: attempt to call method 'gsub' (a nil value) #369

@sufftea

Description

@sufftea

I'm getting this error when trying to edit a single .ts file:

   Error     Error  19:16:08 Error executing vim.schedule lua callback: ...ols.nvim/lua/typescript-tools/protocol/module_mapper.lua:41: attempt to call method 'gsub' (a nil value)
stack traceback:
	...ols.nvim/lua/typescript-tools/protocol/module_mapper.lua:41: in function 'map_method_to_module'
	.../typescript-tools.nvim/lua/typescript-tools/tsserver.lua:132: in function 'request'
	...im.arD7N5i/usr/share/nvim/runtime/lua/vim/lsp/client.lua:679: in function 'request'
	.../lazy/typescript-tools.nvim/lua/typescript-tools/api.lua:152: in function 'request_diagnostics'
	...s.nvim/lua/typescript-tools/autocommands/diagnostics.lua:15: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

I suspected the reason could be not having a full project setup, so I created the config files, but it didn't help:

.
├── npm
├── package.json
├── src
│   └── greeting.ts
└── tsconfig.json

Tried this too, but it didn't help (same error message):

  opts = {
    tsserver_path = function()
      return vim.fn.getcwd()
    end,
  },

My config:

return {
  "pmizio/typescript-tools.nvim",
  enabled = true,
  dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
  opts = {},
}
$ tsc -v
Version 5.9.2
$ nvim.appimage --version
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068

:LspInfo

vim.lsp: Active Clients ~
- typescript-tools (id: 1)
    Root directory: nil
    Command: function: 0x78dc61157bf8
    Settings: vim.empty_dict()
    Attached buffers: 8

vim.lsp: File Watcher ~
- file watching "(workspace/didChangeWatchedFiles)" disabled on all clients

vim.lsp: Position Encodings ~
- No buffers contain mixed position encodings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions