TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

tsconfig.json invalid character

Open mbrandsey opened this issue 10 years ago • 40 comments

TypeScript Version:

1.8.0

Code

create project. create ASP.NET Web Application. create asp.net 5 empty website. create scripts folder in solution. create app folder in wwwroot. create typescript file. create tsconfig.json in scripts folder and build:

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs",
    "outDir": "../wwwroot/app/",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true 
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

Expected behavior: I expect this to build with no errors. What is strange is that this works in Windows 10 but not on my Windows 7 machine with the same set up (Visual studio 2015, update 1, update 2 rc). When you look at the error it is displaying an incorrect path: tsconfig.json/tsconfig.json. It seems to think there is a folder tsconfig.json when there is not. I have ran the tsconfig contents through a json validator to make sure it is correct.

Actual behavior:

Error TS5014 Build: Failed to parse file 'C:/Users/Documents/Visual Studio 2015/Projects/CNAClient/src/CNAClient/scripts/tsconfig.json/tsconfig.json': Invalid character. CNAClient C:\Users\Documents\Visual Studio 2015\Projects\CNAClient\src\CNAClient\VSTSC 1

mbrandsey avatar Apr 01 '16 23:04 mbrandsey

can you share a repro project?

mhegazy avatar Apr 28 '16 16:04 mhegazy

I created an ASP.NET Web Application and then used the Web API template. I installed angular2 via npm install angular2. After including the node_modules folder into the project, it fails with the

VSTSC : error TS5014: Build: Failed to parse file 'E:/Dashboard2015/Dashboard/node_modules/angular2/es6/dev/tsconfig.json/tsconfig.json': Invalid character.

error.

toddpeak avatar Apr 28 '16 17:04 toddpeak

why do you include the node_modules in your project? that tells the task that you want to build the angular code as well.

mhegazy avatar Apr 28 '16 17:04 mhegazy

I did it for source code management purposes, but excluding the node_modules folder from my project did not remedy the problem. Adding my own tsconfig.json file still has the same error message.

toddpeak avatar Apr 28 '16 17:04 toddpeak

Actually, for some reason it's using 1> C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\tsc.exe --project "E:\Dashboard2015\Dashboard\tsconfig.json" 1.5 instead of 1.8.

toddpeak avatar Apr 28 '16 17:04 toddpeak

what is the value of TypeScriptToolsVersion in your project file? (right-click unload, edit project file)

mhegazy avatar Apr 28 '16 18:04 mhegazy

<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>

The only reference "1.5" in the csproj file is the version of WebGrease.

Diagnostic output: 1>Target "CompileTypeScriptWithTSConfig: (TargetId:36)" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\TypeScript\Microsoft.TypeScript.targets" from project "E:\Dashboard2015\Dashboard\Dashboard.csproj" (target "Compile" depends on it): 1>Building target "CompileTypeScriptWithTSConfig" completely. 1>Output file "Components\Dashboard.js" does not exist. 1>Task "VsTsc" (TaskId:15) 1> Task Parameter:ToolPath=C:\Program Files (x86)\Microsoft SDKs\TypeScript (TaskId:15) 1> Task Parameter:ToolExe=tsc.exe (TaskId:15) 1> Task Parameter:TSConfigFile=tsconfig.json (TaskId:15) 1> Task Parameter:YieldDuringToolExecution=True (TaskId:15) 1> Task Parameter:ProjectDir=E:\Dashboard2015\Dashboard\ (TaskId:15) 1> Task Parameter:ToolsVersion=1.8 (TaskId:15) 1> Task Parameter:TypeScriptCompileBlocked=False (TaskId:15) 1> Task Parameter:ComputeOutputOnly=False (TaskId:15) 1> C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\tsc.exe --project "E:\Dashboard2015\Dashboard\tsconfig.json" (TaskId:15) 1>VSTSC : error TS5014: Build: Failed to parse file 'E:/Dashboard2015/Dashboard/tsconfig.json/tsconfig.json': Invalid character. 1> (TaskId:15) 1> The command exited with code 1. (TaskId:15)

toddpeak avatar Apr 28 '16 18:04 toddpeak

can you share a repro project i can look at?

mhegazy avatar Apr 28 '16 18:04 mhegazy

Dashboard.zip

toddpeak avatar Apr 28 '16 18:04 toddpeak

i am getting this error:

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props. Dashboard

mhegazy avatar Apr 28 '16 19:04 mhegazy

I couldn't include the packages in the zip file because it was larger than 10 MB.

toddpeak avatar Apr 28 '16 19:04 toddpeak

restore does not seem to download it for me either. what should i do?

mhegazy avatar Apr 28 '16 19:04 mhegazy

If I just make a new ASP .NET Project and then select Web API, all of those packages are automatically installed.

toddpeak avatar Apr 28 '16 19:04 toddpeak

so ignoring this package, building, here is what i see:

1> C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "c:\test\7781\Dashboard\tsconfig.json"

which is what i expect. can you reproduce these issues on a different machine?

mhegazy avatar Apr 28 '16 19:04 mhegazy

I will try it on another machine, but do you have any guesses as to how my current machine is configured incorrectly or how to fix the configuration? This is my main development machine that is giving me these headaches.

toddpeak avatar Apr 28 '16 20:04 toddpeak

no. if your machine has 1.8 installed, and your TypeScriptToolsVersion is 1.8, 1.8 should always be used.

mhegazy avatar Apr 28 '16 20:04 mhegazy

I uninstalled VS 2015 and reinstalled with the default options. It's now using Typescript 1.8.

toddpeak avatar May 05 '16 18:05 toddpeak

thanks for getting back to us on this. so is the original issue (https://github.com/Microsoft/TypeScript/issues/7781#issuecomment-215497317) resolved?

mhegazy avatar May 05 '16 18:05 mhegazy

Yes, sorry. It's functioning correctly now.

toddpeak avatar May 13 '16 01:05 toddpeak

I had the same issue, but there was only a wrong character in the configfile

thimmy687 avatar Oct 11 '16 08:10 thimmy687