Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode path generation failure in Run Build Task / tsc: build

I am working through the Typescript intro at https://code.visualstudio.com/docs/languages/typescript

When I try to Run Build Task and choose tsc: build, VSCode attempts the following:

Executing task: tsc -p c:\work\JavascriptTypescript\test-apr-2018\tsconfig.json <

error TS5058: The specified path does not exist: 'c:workJavascriptTypescripttest-apr-2018tsconfig.json'.
The terminal process terminated with exit code: 1

It is trying to use the full path to the tsconfig.json file, and then stripping the slashes from that path. Obviously this isn't going to find the correct file.

If I manually issue tsc -p tsconfig.json from the command line, tsc works correctly.

This seems like a VSCode configuration error, but I am new to VSCode and don't know how to fix it.

like image 476
Matt Avatar asked Apr 18 '18 22:04

Matt


3 Answers

This is a known issue (as of 2018-04-20) when using VSCode on Windows with Git Bash as a terminal. See https://github.com/Microsoft/vscode/issues/35593 .

Switching to CMD for a terminal is a workaround. So is invoking tsc manually as described above.

like image 180
Matt Avatar answered Oct 10 '22 15:10

Matt


Change the shell for tasks to cmd.exe

"terminal.integrated.automationShell.windows": "C:\\Windows\\System32\\cmd.exe"

Now you can keep bash as a shell for the terminal and build tasks will be executed using cmd.exe

To change that value

  1. open settings editor CTRL+, or File->Preferences->Settings
  2. in a search, type Automation
  3. Select Edit in settings.json enter image description here

FYI
Can a task use a different shell than the one specified for the Integrated Terminal?

like image 24
v-andrew Avatar answered Oct 10 '22 15:10

v-andrew


Another solution to this problem is to create an npm script that runs tsc, and then run that script in the VSCode launch.json.

package.json:

"scripts": { "debug": "tsc --sourcemap" },

.vscode/launch.json:

{ "type": "node", "request": "launch", "name": "Debugger", "program": "${workspaceFolder}/app.ts", "preLaunchTask": "npm: debug", "outFiles": [ "${workspaceFolder}/*.js" ] }

like image 34
John Avatar answered Oct 10 '22 16:10

John