vscode-extensionsyo

vscode's first extension tutorial: command not listed/breakpoints not hit


Problem description

I followed the vscode tutorial on creating an extension, but I cannot reproduce the behavior of "the command popping up in the Command Palette", nor can I get breakpoints to hit.

My steps

Unfortunately the command hello world doesn't pop up in the list. Neither are the breakpoints hit in extension.ts (like in this part of the tutorial). The breakpoints are unhittable, i.e. their interior is white rather than red. It seems the extension is not being loaded. What am I doing wrong? How can I fix it?

What I tried

I retried many attempts, triple checking my spellings and following of the tutorial. I tried a PC restart. I tried with and without webpack bundling. I reran tsc. I downgraded typescript to 4.7.4 (as later on it warns that 4.8.2 isn't officially supported)

Some possibly relevant version numbers: Windows 10, npm 8.5.5, yo 4.3.0, vscode 1.69.2


Solution

  • Check the version of engines.vscode in package.json:

    The template generated by yo requires the latest vscode the be installed. Change it in the package.json or upgrade vscode.

    More detailed explanation

    I diagnosed the issue by compiling the extension into a VSIX (npm install -g vsce && vsce package). After installing it, I expect the command to be listed in the Command Palette, but don't expect the breakpoint to be hit.

    Upon manually installing the vsix in the Extension development host (extensions -> triple dot -> Install from VSIX), vscode prompted the error

    Unable to install extension undefined.hello-world as it is not compatible with VSCode version 1.69.2

    That gives a hint. In the package.json there was

      "engines": {
        "vscode": "^1.70.0"
      },
    

    but that version is higher than I currently have installed. After changing that to my version, everything started working as advertised.