tsserver: Error processing request (No Project)
Asked Answered
H

3

6

When working on a TypeScript (v2.0+) project within 'Visual Studio Code' (v1.5.3) I get the following error:

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

I restarted visual-studio-code with verbose logging.

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

This gives a bit more information:

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

Does tsserver believe I do not have a project?

I have both a 'tsconfig.json' and 'jsconfig.json' file at the project directory root. I do have a 'tasks.json' that runs tsc. I can stimulate tsserver with other requests with a similar result.

Hearn answered 28/9, 2016 at 15:12 Comment(0)
H
6

As per the tsserver.js source code

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

The verbose log file holds the answer but not reported as an error.

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>

The problem was that there was an empty 'jsconfig.json' file near the top of the 'src' tree ('src/ts/jsconfig.json'). This caused the search for the project root much too low in the file hierarchy. Specifically, the 'tsconfig.json' file was not found resulting in a 'No Project' error.

The executeCommand() function returned undefined, which happens when the associated handler cannot find the project containing the file. The files are associated with the project via the 'files' or 'include' options in the 'tsconfig.json'. The 'tss.log' file should contain 'Info' messages about the files that are opened. Make sure all of the files you care about are opened, in particular check the locations of the 'Config file name' to make sure you are getting the correct files.

This problem did not surface with 'tsc' as it does not consider 'jsconfig.json' as an indicator for a project.

A typical log file should look more like this:

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
...
Hearn answered 28/9, 2016 at 22:56 Comment(2)
This worked for me too! In my case I didn't have a tsconfig.json file, which I thought was fine because my project is JS-only and I have a jsconfig.json file. Once I added an empty tsconfig.json file (contents are {}), suddenly I could "Restart TS Server" from the command palette without having it immediately crash. It is now able to handle all the files in my project without crashing; previously it could only handle half of them, probably because it was picking up neighboring projects since it couldn't find my project root.Ignaciaignacio
I probably had the wrong configuration. With this jsconfig file and no tsconfig file, things are working now: { "compilerOptions": { "outFile": "dist/bundle.js", "lib": [ "ES2016" ], "module": "amd", "checkJs": true }, "include": [ "src" ], "exclude": [ "dist" ] }Ignaciaignacio
C
2

This can happen if you are getting and ignoring this warning: enter image description here

I added the dist folder to tsconfig exclude, which solved the "no project" error and the warning.

  "exclude": [
    ".git",
    "node_modules",
    "**/dist/*",
    "**/node_modules/*",
  ]
Conservancy answered 5/9, 2023 at 14:45 Comment(2)
Please do not post images of code or errors. Text is preferred so that we can try to reproduce the problem without having to re-type everything and your question can be properly indexed or read by screen readers.Birth
Adding build files to exclude worked for me as well in Sublime Text. The error message is very misleading and Sublime text does not have such a warning.Cosimo
V
0

In my case, I noticed that I was having this error in one React project but not the other, so I simply restarted command line and VSCode. For some reason it worked after that.

Volant answered 2/7, 2022 at 15:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.