Does VS Code install TypeScript, and if so: where?

后端 未结 5 1047
借酒劲吻你
借酒劲吻你 2021-01-01 15:22

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:



        
相关标签:
5条回答
  • 2021-01-01 15:29

    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.

    0 讨论(0)
  • 2021-01-01 15:33

    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.

    0 讨论(0)
  • 2021-01-01 15:41

    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

    0 讨论(0)
  • 2021-01-01 15:42

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

    0 讨论(0)
  • 2021-01-01 15:45

    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

    0 讨论(0)
提交回复
热议问题