Bug Report
-
After updating from Microsoft.TypeScript.MSBuild 4.5.3 to 5.1.3 my builds fail with the SyntaxError: Unexpected token '?' error, which is mentioned in the announcement blog post.
-
This happens because:
- TypeScript 5.1 requires Node.js 14+
- But Visual Studio 2019 always uses its own private
node.exe version 12.20 to run TypeScript's tsc.js.
- There does not seem to be a way to configure my MSBuild project to use my systemwide
node.exe (version 18).
- The announcement post does not mention any workaround steps or solution - nor any intentionally breaking compatibility with VS 2019.
-
I looked inside the 5.1.3's Microsoft.TypeScript.targets file and saw it uses the <NodePath> MSBuild property to resolve the path to node.exe - however this always uses $(MSBuildExtensionsPath)\Microsoft\VisualStudio\NodeJs which always resolves to C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs on my computer.
- There doesn't seem to be a way to override or force-set this property in a
.csproj project file: my explicit <NodePath>C:\Program Files\nodejs<NodePath> is always ignored.
🔎 Search Terms
🕗 Version & Regression Information
Since updating from Microsoft.TypeScript.MSBuild version 4.5.3 to 5.1.3 I got stung by the SyntaxError: Unexpected token '?' error, which is mentioned in the announcement blog post.
The change was in this PR: #53291
- This is a crash (insofar as "
node.exe exited with code 1" is a crash)
- This changed between versions 4.x and 5.1
- This is the behavior in every version I tried,
and I reviewed the FAQ for entries about _________
I was unable to test this on prior versions because
⏯ Playground Link
N/A
💻 Code
N/A
🙁 Actual behavior
- Install NodeJS 18+ systemwide (using the official installer).
- When I open a new cmd prompt and run
where node it gives me C:\Program Files\nodejs\node.exe which is v18.16.0 - this happens in both a "normal" cmd prompt as well as the "Developer Command Prompt for VS 2019" version.
- Create an ASP.NET Core project in VS2019 v16.11.26 (I'm targeting .NET Core 3.1)
- Add the
Microsoft.TypeScript.MSBuild NuGet reference - I did it by adding <PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.1.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" /> directly to the <ItemGroup> in the ASP.NET Core project .csproj.
- Add a
tsconfig.json file with "target": "es2022".
- Add a TypeScript
.ts file with some code in it.
- Build the project from within VS (Menu > Build > Build Solution).
- This error will appear in the Error List:
Severity Code Description Project Path File Line Source
Error MSB6006 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe" exited with code 1. MyProject C:\Users\David\.nuget\packages\microsoft.typescript.msbuild\5.1.3\tools C:\Users\David\.nuget\packages\microsoft.typescript.msbuild\5.1.3\tools\Microsoft.TypeScript.targets 485 Build
🙂 Expected behavior
- I expected the
Microsoft.TypeScript.MSBuild package to verify that the version of node.exe that it's using is known compatible and if not to output a warning (not an error) - and if not compatible to output instructions on how to specify the exact path of node.exe to run.
- I expected setting
<NodePath> explicitly in my main <Project><PropertyGroup> to work. However it is ignored because Microsoft.TypeScript.targets always overwrites it.
Bug Report
After updating from
Microsoft.TypeScript.MSBuild4.5.3 to 5.1.3 my builds fail with theSyntaxError: Unexpected token '?'error, which is mentioned in the announcement blog post.This happens because:
node.exeversion 12.20 to run TypeScript'stsc.js.node.exe(version 18).I looked inside the 5.1.3's
Microsoft.TypeScript.targetsfile and saw it uses the<NodePath>MSBuild property to resolve the path tonode.exe- however this always uses$(MSBuildExtensionsPath)\Microsoft\VisualStudio\NodeJswhich always resolves toC:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJson my computer..csprojproject file: my explicit<NodePath>C:\Program Files\nodejs<NodePath>is always ignored.🔎 Search Terms
🕗 Version & Regression Information
Since updating from
Microsoft.TypeScript.MSBuildversion4.5.3to5.1.3I got stung by theSyntaxError: Unexpected token '?'error, which is mentioned in the announcement blog post.The change was in this PR: #53291
node.exe exited with code 1" is a crash)and I reviewed the FAQ for entries about _________I was unable to test this on prior versions because⏯ Playground Link
N/A
💻 Code
N/A
🙁 Actual behavior
where nodeit gives meC:\Program Files\nodejs\node.exewhich isv18.16.0- this happens in both a "normal" cmd prompt as well as the "Developer Command Prompt for VS 2019" version.Microsoft.TypeScript.MSBuildNuGet reference - I did it by adding<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.1.3" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />directly to the<ItemGroup>in the ASP.NET Core project.csproj.tsconfig.jsonfile with"target": "es2022"..tsfile with some code in it.🙂 Expected behavior
Microsoft.TypeScript.MSBuildpackage to verify that the version ofnode.exethat it's using is known compatible and if not to output a warning (not an error) - and if not compatible to output instructions on how to specify the exact path ofnode.exeto run.<NodePath>explicitly in my main<Project><PropertyGroup>to work. However it is ignored becauseMicrosoft.TypeScript.targetsalways overwrites it.