Keep getting "tsc.exe" exited with code 1

JavascriptTypescriptVisual Studio-2015

Javascript Problem Overview


As soon as I add a tsconfig.json file to my Visual Studio 2015 web solution I get the above error.

Also this stops the compiler from re-generating js files even when I set "compileOnSave": true.

When I double click the error it takes me into the Microsoft.Typescript.Targets file which contains a lot of issues such as Unknown Item Group "TypeScriptCompile". In the error list these appear as warnings but they are there whether I have a tsconfig.json file or not.

Is there any way of solving it or getting more information on what the problem is?

Javascript Solutions


Solution 1 - Javascript

Install these 2 NuGet packages:

Microsoft.TypeScript.MSBuild and Microsoft.TypeScript.Compiler

It updates your project with MSBuild task definition and TS compiler and solves the compilation issue

Solution 2 - Javascript

For me installing TypeScript for Visual Studio fixed it, although TypeScript was already installed globally on my machine via npm

Solution 3 - Javascript

I am using a .NET Core 1.0 project and ran into the same situation of getting a tsc.exe return code of 1. My problem was an invalid tsconfig.json. However, msbuild does not provide those details.

The easiest way to find out is to enable detailed output in Visual Studio -> Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild project build output verbosity. Change this to Detailed. After compiling, find tsc.exe in the output window to see the actual error tsc was throwing.

Solution 4 - Javascript

I had this problem as well after using some standard Angular / Typescript tutorials. The solution was as simple as to update typescript in Visual Studio.

For some reason the default is now 1.8.4. and it does not allow you to automatically update it from Visual Studio Extensions and does not say it is out of date. You just download it from here and install newest version yourself. Download link may change in the future of course.

P.S. I think the problem was caused by the fact that some options that did not exist in older compiler were used.

Solution 5 - Javascript

This worked for TeamCity build server with Visual Studio 2015 when I had upgraded a project from Typescript 1.8 to 2.3

  • Install package Microsoft.TypeScript.MSBuild
  • Update *.csproj as follows
  1. Upgrade TypeScriptToolsVersion to 2.3 (in this case)
  2. Remove two lines of Import Project that referred to Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets
Note
  • Removing the import elements is important as they are referring to TypeScript installed in the %PROGRAMFILES(X86)% folder.
  • Installing the package adds import elements that reference the packages folder - making your build more portable

Solution 6 - Javascript

I had same issue and what happened in my case is that the file .ts was in the project but it was not on file system. Something like this missing file on filesystem. So removed the file from project and everything started to work again.

Solution 7 - Javascript

Move all files within C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Typ‌​escript into some new folder (e.g. backup), then try again. This will cause MSBuild to select tsc.exe from within the appropriately versioned folder instead of using the one in the C:\Program Files (x86)\Microsoft SDKs\TypeScript.

Solution 8 - Javascript

Installing Microsoft.Typescript.MsBuild fixed the issue for me, but only if I installed the penultimate version. The current (stable) version is 2.0.6, and after I installed it, the issue persisted. When I reverted to 1.8.11, the issue went away.

Solution 9 - Javascript

I had the same issue. Fixed it by removing the following from the project file

<TypeScriptToolsVersion>2.0</TypeScriptToolsVersion>

Solution 10 - Javascript

Double clicking on one of the .ts files inside of visual studio worked for me. It then came up with a dialog box asking if I wanted to update the project to the latest version of TS. After that the project built fine and the compile error was gone.

Solution 11 - Javascript

There is need to Re-Install/Upgrade, Typescript in your system.

As i was facing same issue and after installing Typescript again got resolved the error, as tsc.exe was missing in (C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1).

Solution 12 - Javascript

We are using npm and angular-cli outside VS to transpile our typescript. I ran into the problem described above on the only dev box that had the Web Essentials extension loaded. After trying installing, and then uninstalling the MS nugets and TypeScript extension described above to no avail, uninstalling Web Essentials finally did the trick.

Solution 13 - Javascript

I was facing same issue, and the reason was, 2 developers were working on same project so when he added new .ts files into project and some angular controllers. The project was rebuilding and running as expected however when another developer tried to take latest source code on his machine and on rebuilding he was getting same error "tsc.exe" exited with code 1. So reason was the files created/added in source control was not showing added on developer 2 solution. Please try to check if all the .ts, .js files are up to date on both developers solution.

Solution 14 - Javascript

I had the same issue on a solution using AngularJS but without the compiler (below 2.x so not needed). I simply removed the index.d.ts from script folder and it was ok (no NuGet packages necessary)

Solution 15 - Javascript

If youre are facing this problem when updating from bootstrap 3 to 4 just delete .ts file created inside the Scripts Folder then build again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFrank CannonView Question on Stackoverflow
Solution 1 - JavascriptDmitry VasilievView Answer on Stackoverflow
Solution 2 - JavascriptMohamed BadrView Answer on Stackoverflow
Solution 3 - JavascriptthoeanView Answer on Stackoverflow
Solution 4 - JavascriptIlya ChernomordikView Answer on Stackoverflow
Solution 5 - JavascriptfiatView Answer on Stackoverflow
Solution 6 - JavascriptJernej NovakView Answer on Stackoverflow
Solution 7 - JavascriptJosh M.View Answer on Stackoverflow
Solution 8 - JavascriptJon CrowellView Answer on Stackoverflow
Solution 9 - JavascriptNirbhay JhaView Answer on Stackoverflow
Solution 10 - JavascriptCrazometerView Answer on Stackoverflow
Solution 11 - JavascriptManveer SinghView Answer on Stackoverflow
Solution 12 - JavascriptperlykingView Answer on Stackoverflow
Solution 13 - JavascriptSagar PawarView Answer on Stackoverflow
Solution 14 - Javascriptuser9703340View Answer on Stackoverflow
Solution 15 - Javascriptsubramanya46View Answer on Stackoverflow