gpt4 book ai didi

typescript - tsserver : Error processing request (No Project)

转载 作者:搜寻专家 更新时间:2023-10-30 21:05:46 24 4
gpt4 key购买 nike

在“Visual Studio Code”(v1.5.3) 中处理 TypeScript (v2.0+) 项目时,出现以下错误:

[Error - 10:03:50 AM] 'format' request failed with error.
Error processing request. No Project.
Error: No Project.
...

我重新启动了带有详细日志记录的 visual-studio-code。

export TSS_LOG='-level verbose -file <my-home>/tss.log'

这提供了更多信息:

Info 1233 request: {"seq":522,"type":"request","command":"format","arguments":{"file":"/<my_project>/src/ts/<the-file>.ts","line":1,"offset":1,"endLine":616,"endOffset":1}}

Err 1234 Exception on executing command {"seq":522,"type":"request","command":"format","arguments":{"file":"/<my_project>/src/ts/<the-file>.ts","line":1,"offset":1,"endLine":616,"endOffset":1}}:
No Project.
Error: No Project.
at Errors (<my_global_node>/lib/node_modules/typescript/lib/tsserver.js:50793:32)
at ts.server.ts.server (<my_global_node>/lib/node_modules/typescript/lib/tsserver.js:50795:11)
at ts (<my_global_node>/lib/node_modules/typescript/lib/tsserver.js:51775:7)
at Object.<anonymous> (<my_global_node>/lib/node_modules/typescript/lib/tsserver.js:51776:3)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)

Info 1235 response:
{"seq":0,"type":"response","command":"format","request_seq":522,"success":false,"message":"Error processing request. No Project.
Error: No Project.
at Errors (/home/fred/.nvm/versions/node/v6.5.0/lib/node_modules/typescript/lib/tsserver.js:50793:32)
at ts.server.ts.server (/home/fred/.nvm/versions/node/v6.5.0/lib/node_modules/typescript/lib/tsserver.js:50795:11)
at ts (/home/fred/.nvm/versions/node/v6.5.0/lib/node_modules/typescript/lib/tsserver.js:51775:7)
at Object.<anonymous> (/home/fred/.nvm/versions/node/v6.5.0/lib/node_modules/typescript/lib/tsserver.js:51776:3)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)"}

tsserver 认为我没有项目吗?

我在项目目录根目录下有一个“tsconfig.json”和“jsconfig.json”文件。我确实有一个运行 tsc 的“tasks.json”。我可以用具有类似结果的其他请求来刺激 tsserver。

最佳答案

根据 tsserver.js source code

$ export TSS_LOG='-level verbose -file <my-home>/tss.log'
$ code

详细日志文件包含答案但未报告为错误。

Info 2    Config file name: /<my-project>/src/ts/jsconfig.json
Err 3 Exception on executing command {"seq":0,"type":"request","command":"open","arguments":{"file":"<my-project>/src/ts/<a-class-file>.ts","fileContent":"..."}}: Unexpected end of input
<stack-trace>

问题是在“src”树(“src/ts/jsconfig.json”)顶部附近有一个空的“jsconfig.json”文件。这导致在文件层次结构中搜索项目根目录太低。具体来说,找不到导致“无项目”错误的“tsconfig.json”文件。

executeCommand() 函数返回未定义,当关联的处理程序找不到包含该文件的项目时会发生这种情况。这些文件通过“tsconfig.json”中的“files”或“include”选项与项目相关联。“tss.log”文件应包含有关打开的文件的“信息”消息。确保您关心的所有文件都已打开,特别是检查“配置文件名”的位置以确保您获得正确的文件。

这个问题没有出现在“tsc”中,因为它没有将“jsconfig.json”视为项目的指标。

一个典型的日志文件应该看起来更像这样:

Info 0    request: {"seq":0,"type":"request","command":"open","arguments":{"file":"/<my-project>/src/ts/folder1/ClassA.ts","fileContent":"..."}}
Info 1 Search path: /<my-project>/src/ts/folder1
Info 2 Config file name: /<my-project>/tsconfig.json
Err 3 Add recursive watcher for: /<my-project>
Err 4 Add recursive watcher for: /<my-project>/src/ts
Info 5 Opened configuration file /<my-project>/tsconfig.json
Info 6 Project (configured) 0
/<node-root>/lib/node_modules/typescript/lib/lib.es6.d.ts
/<my-project>/node_modules/@types/bluebird/index.d.ts
...a list of all the project files...

-----------------------------------------------
Open file roots of inferred projects:
Open files referenced by inferred or configured projects:
Open file roots of configured projects:
/<my-project>/src/ts/folder1/ClassA.ts
Perf 7 Async elapsed time (in milliseconds): 1060.9415
...

关于typescript - tsserver : Error processing request (No Project),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39751420/

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