skip to Main Content

I init my first vscode extension following this page.

Here is my steps:

  1. npm install -g yo generator-code
  2. yo code

And here is the package.json generated:

{
  "name": "helloworld",
  "displayName": "helloworld",
  "description": "description helloworld",
  "version": "0.0.1",
  "engines": {
    "vscode": "^1.72.0"
  },
  "categories": [
    "Other"
  ],
  "activationEvents": [
    "onCommand:helloworld.helloWorld"
  ],
  "main": "./out/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "helloworld.helloWorld",
        "title": "Hello World"
      }
    ]
  },
  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
  },
  "devDependencies": {
    "@types/glob": "^8.0.0",
    "@types/mocha": "^10.0.0",
    "@types/node": "16.x",
    "@types/vscode": "^1.72.0",
    "@typescript-eslint/eslint-plugin": "^5.38.1",
    "@typescript-eslint/parser": "^5.38.1",
    "@vscode/test-electron": "^2.1.5",
    "eslint": "^8.24.0",
    "glob": "^8.0.3",
    "mocha": "^10.0.0",
    "typescript": "^4.8.4"
  }
}

When I press H5 to debug, I got no command matched here:
enter image description here

I was stuck here for a while, where is my command??

2

Answers


  1. I’ve encountered this just now as well. Make sure that engines.vscode in package.json matches the version of vscode you are running:

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

    I guess the generator will use the latest version available, but you might not have upgraded yet. That was the case for me.

    Login or Signup to reply.
  2. @tacospice pointed out exactly. in package.json, engines.vscode determines minimum version of VSCode. In my case, yo created extension template which set minimum VSCode version(1.74.0) newer than working VSCode(1.70.0). Check Help -> About -> version with package.json.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search