Search code examples
javascripttypescriptvisual-studiovisual-studio-2019

Visual Studio 2019 is not showing completions when using TypeScript 5.1, and breakpoints cannot be set in TypeScript files


Visual Studio 2019 is not showing completions in JavaScript or TypeScript files after installing TypeScript 5.1, and trying to set breakpoints in a JavaScript or TypeScript file gives the error message: "A breakpoint could not be inserted at this location". Additionally, the output window shows the message: “The JavaScript and TypeScript language service has been disabled after crashing repeatedly. You may see reduced IntelliSense support for your project. Please try reloading your solution to reenable the language service.”


Solution

  • What's happening here is that Visual Studio 2019 ships with Node 12, and TypeScript 5.1 is using some newer JavaScript syntax that is only supported in Node 14 and up. To work around this, you can make Visual Studio use Node 16 by,

    1. Installing Node 16 from nodejs.org if you don't already have one of these version of Node installed on your machine. (We've tested both Node 16 and Node 14 and both work correctly with Visual Studio 2019)
    2. Modifying the registry to tell Visual Studio to use the Node version you installed. To do this, open regedit.exe, and under the path, HKCU\Software\Software\Microsoft\VisualStudio\16.0_xxx\TypeScriptLanguageService, add a string value named “CustomNodePath” and set the value data to be the path to your Node install. By default, this should be C:\Pogram Files\nodejs\node.exe.

    After that, Visual Studio should be using Node 16 to run the JavaScript/TypeScript language service and everything should work as before.