1

enter image description here

I am using NeoVim with CoC for TS development of yarn-3 pnp-enabled project. At some point the editor stopped seeing imports and started complaining that the imported module does not exist. (see screenshot). I already configured SDK for vim and installed ts sdks, updated yarn and restarted the editor. Here are some details: OS:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

Neovim:

NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by team+vim@tracker.debian.org

package.json:

{
  "private": true,
  ...
  "devDependencies": {
    "typescript": "4.5.5",
  },
  "packageManager": "yarn@3.5.0"
}

.yarnrc.yml

checksumBehavior: update

nodeLinker: pnp

plugins:
  - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
    spec: "@yarnpkg/plugin-workspace-tools"
  - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
    spec: "@yarnpkg/plugin-typescript"

yarnPath: .yarn/releases/yarn-3.5.0.cjs

tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist/",
    "noImplicitAny": true,
    "skipLibCheck": true,
    "module": "es6",
    "target": "es6",
    "jsx": "react",
    "allowJs": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "paths": {
      "@company/xxx-rqb": ["./packages/xxx-rqb/src"]
    }
  },
  "exclude": ["**/*.test.ts", "**/*.spec.ts"]
}

.vim/coc-settings.json:

{
  "eslint.packageManager": "yarn",
  "eslint.nodePath": ".yarn/sdks",
  "workspace.workspaceFolderCheckCwd": false,
  "tsserver.tsdk": ".yarn/sdks/typescript/lib"
}

CocInfo:

## versions

vim version: NVIM v0.7.2
node version: v16.15.1
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: /home/user/.nvim/plugin/coc.nvim
term: tmux
platform: linux

## Log of coc.nvim

2023-04-11T18:17:33.885 INFO (pid:911582) [configurations] - Add folder configuration from cwd: /home/user/dev/reactfrontend/.vim/coc-settings.json
2023-04-11T18:17:34.057 INFO (pid:911582) [plugin] - coc.nvim initialized with node: v16.15.1 after 224
...
coc-tsserver veriosn 2.1.3 (latest)
All plugins are updated.
Yarn SDKs installed for typescript, prettier, eslint. Integrations: vim.

I already tried upgrading yarn, upgrading sdks, upgrading neovim, reinstall dependencies. Tried yarn tsc with a single simple file which had no errors and generated some js.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • Guessing you already saw this but for future searchers, relevant docs: https://yarnpkg.com/getting-started/editor-sdks#cocnvim – Jared Smith Apr 11 '23 at 13:45
  • 1
    You are correct. However, that document does not mention the setting I had to change (see the answer). – user4756260 Apr 13 '23 at 11:04

1 Answers1

3

Eventually found that I had to change coc ts version using this commands:

:CocCommand tsserver.chooseVersion

And select Local version instead of Bundled with coc-tsserver