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.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
DeborahK
  • 57,520
  • 12
  • 104
  • 129

5 Answers5

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.

DeborahK
  • 57,520
  • 12
  • 104
  • 129
  • 1
    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." https://code.visualstudio.com/Docs/languages/typescript – Bo Chen Dec 20 '16 at 00:33
  • 1
    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). https://code.visualstudio.com/Docs/languages/typescript – Albert Einstein Sep 15 '17 at 05:45
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.

vitaminjeff
  • 588
  • 6
  • 9
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

Pierre Goch
  • 109
  • 3
  • 3
    where did you put: "command": "C:/Users/user1/AppData/Roaming/npm/tsc.cmd", "isShellCommand": "false" – napstercake Aug 02 '17 at 15:25
  • 1
    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`. – Andrew Gray Nov 19 '18 at 18:57
2

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

natemcmaster
  • 25,673
  • 6
  • 78
  • 100
  • 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. – DeborahK Jul 02 '15 at 16:59
  • 1
    The error I get is "'tsc' is not recognized as an internal or external command, operable program or batch file." – DeborahK Jul 02 '15 at 17:05
  • Have you tried following http://blogs.msdn.com/b/typescript/archive/2015/04/30/using-typescript-in-visual-studio-code.aspx? – natemcmaster Jul 02 '15 at 17:06
  • 1
    Also, have you installed Typescript globally? `npm install -g typescript` – natemcmaster Jul 02 '15 at 17:07
  • 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. – DeborahK Jul 02 '15 at 17:08
  • I was asking whether VS Code installs the TypeScript compiler. So should I assume by your suggestion of using npm means that your original answer was wrong? So is it "No, VS Code does *not* install the TypeScript compiler. It needs to be installed separately using npm"? – DeborahK Jul 02 '15 at 17:11
  • BTW ... it was this post: http://stackoverflow.com/questions/29972103/in-vs-code-how-to-use-the-typescript-1-5-alpha-compiler in a reply at the bottom that made me wonder whether VS Code "ships with" TypeScript. – DeborahK Jul 02 '15 at 17:14
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

ChristianB
  • 63
  • 5