18

I recently read that installing VS Code also installs the TypeScript compiler. Is this true? If so, where is it installed?

I found a tsc.js file here:

C:\Users\Deb\AppData\Local\Code\app-0.3.0\resources\app\server\lib\typeScript

But I am not finding a tsc.exe anywhere.

5 Answers 5

28

After some trial and error I came to the conclusion that VS Code does NOT install the TypeScript compiler.

The TypeScript compiler does have to be manually installed using npm install -g typescript.

If installing under Windows on a machine that has had Visual Studio 2012/2013/2015 installed, the machine may also have other versions of TypeScript installed here: C:\Program Files (x86)\Microsoft SDKs\TypeScript\

If that is the case, VS Code may try to use the version installed there. To prevent this, remove any references to the above TypeScript path from the environment path variable.

To check the default version of the TypeScript compiler that will be found, use the command line and type: tsc -v. This should give you the version number.

Sign up to request clarification or add additional context in comments.

2 Comments

Agreed.. but the official documents says: "VS Code ships with a recent stable version of TypeScript. It also performs version checking for any version of TypeScript you may have installed globally or locally in your workspace." code.visualstudio.com/Docs/languages/typescript
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc. You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript (tsc HelloWorld.ts). code.visualstudio.com/Docs/languages/typescript
6

I ran across this issue while attempting to build some TypeScript in Visual Studio Code while following along in @DeborahK's Pluralsight course "Angular with TypeScript".

I came across the same error message in the Visual Studio Code OUTPUT panel.

'tsc' is not recognized as an internal or external command, operable program or batch file.

I had recently done a global installation of TypeScript 1.8.9 from npm.

npm install -g typescript

However, checking the TypeScript compiler version in my cmd shell would show an older version, 1.3.0.

$ tsc -v

To get around this, I removed references from the "Path" variable in my "System variables" (Advanced system settings > Environment Variables... > System variables). I removed the following path:

C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.1\

I learned that the Visual Studio 2013 installation I also had on the same machine included an installation of TypeScript 1.3.0. Cleaning my "Path" variable fixed the output on my TypeScript compiler version check.

Sadly, I still had the issue in Visual Studio Code. The thing that inevitably fixed it for me was a reboot.

If you got this far down in the thread, that's what fixed it for me. YMMV.

Comments

3

Shell command 'tsc' still giving error about command not found, although I had run

  • npm install -g typescript (and tsc -v returns version 1.7.5)

In the end I used external command:

  • "command": "C:/Users/user1/AppData/Roaming/npm/tsc.cmd",

  • "isShellCommand": "false"

And then it built

2 Comments

where did you put: "command": "C:/Users/user1/AppData/Roaming/npm/tsc.cmd", "isShellCommand": "false"
As someone also having this problem and also isn't too knowledgeable about VS Code, this answer isn't helpful because information is clearly missing. Did you create a custom command? I know this can't be a Build Task, because they don't allow for either command or isShellCommand.
2

You found it. tsc.js is the entry point for the TypeScript compiler. There is no tsc.exe.

7 Comments

Thanks, but how then does VS Code find the compiler when I build? If I point my tasks.json file to the version of TypeScript installed by Visual Studio, it compiles. If I remove the version installed by Visual Studio, and try to use what came with VS Code, then nothing happens when I try to build.
The error I get is "'tsc' is not recognized as an internal or external command, operable program or batch file."
Also, have you installed Typescript globally? npm install -g typescript
Yes. It says this: "Out of the box, Visual Studio Code supports TypeScript 1.5 beta and using either the node or Visual Studio command-line compilers. For this quickstart, because of its use of the new tsconfig.json feature, we assume you already have TypeScript 1.5 beta installed." Hence I was confused as to whether or not VS Code came with the TypeScript compiler or whether I needed to install it.
|
0

To be clear: VS Code does not bring a TS Compiler. You currently have two Options:

  1. VS 2013/2015 Plugin (brings tsc.exe) => You do not Need VStudio for this Plugin to run.
  2. Using NodeJS & installing TS Compiler via package Manager npm

I recommend to all VS Code users to install NodeJS. In fact, the main things needed for compiling are in tsc.js, which need to be run in a host (=by any JavaScript execution engine). This can be either tsc.exe or nodejs, however, there are differences. NodeJS allows watching a file (e.g. using libuv for detecting changes on saving a ts file to compile automatically). I recommend NodeJS as Long as you do not use VStudio. TSC.exe might(!) be faster because it runs on Chakra now, which is the new Edge-Engine. However, NodeJS uses Google v8 which should also be quite fast. I also experienced PATH-Problems with tsc.exe. VS Code really runs independent from the compiler, it is not merged with the Compiler as heavy as msbuild with vstudio. Therefore VSCode will fail if there is no PATH entry. I never had Problems with NodeJS.

Best, Christian

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.