43

I just started playing with Visual Studio Code and when I created a new file called index.html, I am shown this warning message

A version mismatch between the globally installed tsc compiler (1.0.3.0) and VS Code's language service (1.8.10) has

Can someone please guide me what i have to do to fix this.

Is this serious or I can ignore. I googled but could not get much info

Thanks

enter image description here

1

12 Answers 12

28

I added this to my settings.json file, accessed through preferences > Workspace Settings :

"typescript.tsdk": "node_modules/typescript/lib"

now I no longer receive this error and in the bottom right corner of my screen it shows the current version of Typescript that I have installed.

3
  • 1
    This is the correct answer on Windows (no need for the long explicit path)
    – david.pfx
    Oct 11, 2016 at 3:54
  • 1
    File > Preferences > Workspace Settings (Thanks to code.visualstudio.com/Docs/customization/userandworkspace)
    – Reid
    Dec 15, 2016 at 20:58
  • 2
    On Windows, when I used "typescript.tsdk": "node_modules/typescript/lib", I get a warning The path c:\temp\typescript\code\node_modules\typescript\lib doesn't point to a valid tsserver install. Falling back to bundled TypeScript version. I had to use the full path. "typescript.tsdk": "C:\\Users\\wekel\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib" I am using VS Code 1.9.1. Feb 24, 2017 at 14:59
21

[UPDATE] VS Code 1.6 now ships with TypeScript 2.0.3.

I just installed the latest Typescript, currently v.2.0.3, and installed VS Code v.1.5.3 on macOS Sierra. For some reason, exactly following the official doc didn't work for me.

Here's how I made it work:

After having installed the latest version globally: npm i -g typescript, I added the following line to my settings.json file (opened by cmd + ,):

"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib",

Hope this helps someone else.

[update] as @ptpaterson mentioned on the comment below, on Windows the path is: "typescript.tsdk": "C:/Users/{user_name}/AppData/Roaming/npm/node_modules/typescript/lib/"

4
  • 4
    "typescript.tsdk": "C:/Users/{user_name}/AppData/Roaming/npm/node_modules/typescript/lib/" for me on windows. But this is what I needed.
    – ptpaterson
    Oct 5, 2016 at 18:16
  • 1
    Thank you for that @ptpaterson. I added this info to the answer. Oct 5, 2016 at 18:56
  • 1
    @rafaelbiten There's two hidden characters in your windows path. /types^^cript/lib . Please remove them Oct 7, 2016 at 11:36
  • 1
    @AbuAbdullah Just removed the hidden spaces. Thank you! Oct 7, 2016 at 11:42
11

You have to change the version of TypeScript that Visual Code is using to match the version you have installed:

https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions

The above is taken from the link:

If you want to use a newer version of TypeScript, you can define the typescript.tsdk setting (File > Preferences > User/Workspace Settings) pointing to a directory containing the TypeScript tsserver.js file.

You can find the installation location using npm list typescript, tsserver.js is usually under the lib folder.

For example:

{
    "typescript.tsdk": "node_modules/typescript/lib"
}
9

You have to update your Typescript installation and restart Code afterwards:

npm install -g typescript

or

npm install -g typescript@1.8.10

The message should not longer appear, if it worked.

1
  • I did not work. I had to suppress the message by clicking dont check again.
    – VivekDev
    Sep 22, 2016 at 4:32
9

This error was being generated because I had a reference to an older installation of TypeScript in my System Path variable:

C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\

The Visual Studio Code error was resolved when I removed this entry.

However, my TypeScript files then failed to transpile as the build action couldn't find the tsc.exe file.

When the SDK is installed (through Visual Studio or via a manual *.visx install), a tsc.exe file is installed and the PATH environment variable is updated to reference the folder that this file resides in (see above).

There is another way to transpile your files on a Windows environment by using node.js:

  • Install node.js. Installation packages can be found here.
  • Use npm to install TypeScript:

    npm install -g typescript

    This will add the TypeScript files to your profile AppData folder:

    C:\Users\{your_user_name}\AppData\Roaming\npm\node_modules\typescript\lib

  • Configure your Visual Studio Code user settings.json file to reference this folder:

    {
    "typescript.tsdk": "C:\\Users\\{your_user_name}\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib"
    }
  • Add / update the user PATH environment variable to reference the folder that contains the tsc.cmd file:

    %USERPROFILE%\AppData\Roaming\npm

5

None of the solutions above worked for me - first of all this is the global tsc I want to have updated to the latest version.

After I did some investigation it turned out that the problem lies in system's PATH variables; tsc.cmd (along with tscserver.cmd) exists in these locations:

  • c:\Program Files\nodejs - where the npm.exe and node.exe are
  • %USERPROFILE%\AppData\Roaming\npm - where global packages are

What you can do is to juggle environment\user variables so the tsc command would be resolved from %USERPROFILE% first instead of Program Files.

The quick & dirty way would be just deleting tsc.cmd and tscserver.cmd from the Program Files path.

4

Installing v2.0.3 of typescript was not sufficient... but but then updating the version dependency on package.json worked for me.

Npm command:

npm install -g typescript@2.0.3

Updated line on package.json:

"typescript": "^2.0.3"
2

The cause of my experience with this issue (in VSCode 1.8 on Mac OS X 10.12.2) was that I have been using NVM and while my code was running on the NVM version, VSCode was looking at a system installation of node.

Double check which installation of npm you are using to install typescript globally. If in doubt (on linux/mac) use which tsc from the command-line to verify the location being used by VSCode.

For example, if I simply call npm i -g typescript, npm resolves to ~/.nvm/versions/node/v6.9.1/bin/npm. I had to solve the problem by calling /usr/local/bin/npm i -g typescript explicitly because VSCode looks for node in /usr/local/bin/node by default.

1

Install TypeScript globally to share the installation across workspaces. In this case, you install it using npm install -g typescript@next.

You then have to tell VS Code on setting.json file (File -> Preferences -> Workspace Settings) the install location using the typescript.tsdk setting. Set typescript.tsdk to the path of the lib folder containing the tsserver.js file of the installed TypeScript module.

On windows: "typescript.tsdk": "C:/Users/<MyUser>/AppData/Roaming/npm/node_modules/typescript/lib"

On Mac: "typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib"

1

Installing VSCode 1.6.0 fixed the TypeScript version mismatch warning message for me.

0

You'd think that this being a Microsoft product they'd give the Windows paths on their website

https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions

but they don't. They only give the Unix path types. Use:- On windows: "typescript.tsdk": "C:/Users/YourNameHere/AppData/Roaming/npm/node_modules/typescript/lib/"

Note that forward strokes must be used even though Windows uses backstrokes for the paths!

Some other answers miss off the last forward stroke which is necessary.

6
  • 1
    On windows, use escaped backslashes for paths: "C:\\Users\\YourNameHere\\AppData\\... Jun 5, 2017 at 18:33
  • Sorry mate, but voted this down because this does not seem an answer but it is rather a comment. If you meant it to be an answer, then it seems irrelevant to the problem. Perhaps you could edit it to be more clear about how does the path and the path format solve this issue or remove it and place this as a comment where it belongs. I'll vote it up then. :)
    – AlexRebula
    Jul 26, 2017 at 14:14
  • 1
    @AlexRebula I'm not allowed to make any comments on other user's answers and the more I get voted down the further that possibility is.
    – Quentin 2
    Jul 27, 2017 at 15:02
  • Hey Quentin. You have a point there if that is so. :) I tried voting it back up, but it said that since I already voted it, your answer must be edited first. See prntscr.com/g16eai
    – AlexRebula
    Jul 27, 2017 at 22:17
  • Perhaps edit it a little and I'll cast back my vote for you. Cheers.
    – AlexRebula
    Jul 27, 2017 at 22:18
0

You can just remove 'typescript.tsdk' and use the one embedded in Code if you don't really care about which tsdk version you use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.