gpt4 book ai didi

typescript - 无法使用 coc-tsserver 找到模块 (ts2307)

转载 作者:行者123 更新时间:2023-12-03 07:56:16 28 4
gpt4 key购买 nike

enter image description here

我正在使用 NeoVim 和 CoC 来进行支持yarn-3 pnp 的项目的 TS 开发。在某些时候,编辑器不再看到导入并开始提示导入的模块不存在。 (参见屏幕截图)。我已经为vim配置了SDK并安装了ts sdks,更新了yarn并重新启动了编辑器。以下是一些细节:操作系统:

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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4d0c1c5c98fd2cdc9e4d0d6c5c7cfc1d68ac0c1c6cdc5ca8acbd6c3" rel="noreferrer noopener nofollow">[email protected]</a>

package.json:

{
"private": true,
...
"devDependencies": {
"typescript": "4.5.5",
},
"packageManager": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90e9f1e2fed0a3bea5bea0" rel="noreferrer noopener nofollow">[email protected]</a>"
}

.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"
}

Coc信息:

## 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、升级sdks、升级neovim、重新安装依赖项。使用一个简单的文件尝试了yarn tsc,没有错误并生成了一些js。

最佳答案

最终发现我必须使用以下命令更改 coc ts 版本:

:CocCommand tsserver.chooseVersion

并选择本地版本而不是与coc-tsserver捆绑

关于typescript - 无法使用 coc-tsserver 找到模块 (ts2307),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75986441/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com