2

當 'Visual Studio代碼'(V1.5.3)我收到以下錯誤內的打字稿(V2.0 +)項目的工作:tsserver:錯誤處理請求(無項目)

[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相信我沒有一個項目?

我在項目目錄root下有一個'tsconfig.json'和'jsconfig.json'文件。 我確實有一個運行tsc的'tasks.json'。 我可以通過其他類似結果的請求來激發tsserver。

回答

5

由於每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()函數返回undefined,當關聯的處理函數找不到包含文件的項目時發生。 這些文件通過'tsconfig.json'中的'files'或'include'選項與項目關聯。 'tss.log'文件應該包含有關打開文件的'Info'消息。確保您關心的所有文件都已打開,特別是檢查「配置文件名」的位置以確保您獲得正確的文件。

這個問題沒有用'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 
...