Reputation: 60578
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.
Upvotes: 18
Views: 18236
Reputation: 63
To be clear: VS Code does not bring a TS Compiler. You currently have two Options:
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
Upvotes: 0
Reputation: 608
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.
Upvotes: 6
Reputation: 109
Shell command 'tsc' still giving error about command not found, although I had run
In the end I used external command:
"command": "C:/Users/user1/AppData/Roaming/npm/tsc.cmd",
"isShellCommand": "false"
And then it built
Upvotes: 3
Reputation: 60578
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.
Upvotes: 28
Reputation: 26823
You found it. tsc.js is the entry point for the TypeScript compiler. There is no tsc.exe.
Upvotes: 2