You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用NeoVim+CoC开发Yarn3 PNP项目遇coc-tsserver模块找不到(TS2307)

问题:NeoVim + CoC 无法识别 Yarn 3 PNP 项目中的 TypeScript 导入模块

编辑器提示导入模块不存在

使用NeoVim搭配CoC插件,在启用PNP的Yarn 3项目中开发TypeScript时,编辑器无法识别导入模块,持续提示“导入的模块不存在”。已配置Vim SDK、安装TypeScript SDK、更新Yarn并重启编辑器,问题仍未解决。yarn tsc编译单个文件无报错且能生成JS,但编辑器提示问题依旧。

环境与配置详情

操作系统

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.

已尝试的操作:升级Yarn、升级SDK、升级NeoVim、重新安装依赖。


内容的提问来源于stack exchange,提问作者user4756260

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 04:53:17