No TypeScript compiler was found at C:\\Program Fi

2020-02-14 05:35发布

问题:

I installed Visual Studio 2015 and TypeScript 1.8.6 for Visual Studio 2015. After creating a new TypeScript project and building, I get this build error:

No compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe

Indeed, tsc.exe is missing in the file system.

Things I've tried:

  • Uninstall and re-install TypeScript Tools for Visual Studio 2015 1.8.6.0
  • Uninstall and re-install TypeScript Tools for Visual Studio 2013 1.8.5.0
  • Repair TypeScript Tools for Visual Studio 2015 1.8.6.0
  • I HAVE tried turning it off and on again :-)

Any clue on how to solve this? Which component installs the TypeScript SDK?

回答1:

MSBuild is looking in the wrong place for tsc.exe

It should be looking in 'C:\Program Files (x86)\Microsoft SDKs\TypeScript\ tsc version \tsc.exe'

e.g. C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe

The one thing the TypeScript SDK installer wont do, is upgrade your existing projects. So all that reinstalling wont change anything. However, if you want MSBuild to use the newer compiler, you can upgrade your project yourself.

I don't think there is any way to do this through the UI, but it's easy enough to edit the Project file. It needs to contain this in the first PropertyGroup

<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>

If you want the build to use v1.8.6, you need to set

<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>

In your case, I'm betting it's not there at all. So you should just add it.



回答2:

I'm not experienced with using the TypeScript tools for Microsoft.. what you could do is use Gulp or Grunt tasks to compile TypeScript, this will even allow you to compile the TypeScript files everytime your save your .ts files.

You will need NPM (Node Package Manager) to install Gulp or Grunt and then install the package for compiling TypeScript.

You can find some information about the Grunt TypeScript package here: https://www.npmjs.com/package/grunt-typescript

Or for information about the Gulp TypeScript package, check this: https://www.npmjs.com/package/gulp-typescript



回答3:

I've read through the comments on this issue on the TypeScript Github repo. Although this is a different issue, I did find a clue: repairing Visual Studio 2015 (through the Control Panel) installed tsc.exe in the correct folder.