为什么我初始化第一个 vscode 扩展时没有匹配的命令?

问题描述 投票:0回答:3

我在此页面之后初始化了我的第一个 vscode 扩展。

这是我的步骤:

  1. npm install -g yo 生成器代码
  2. 哟代码

这是生成的package.json:

{
  "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"
  }
}

当我按H5进行调试时,我在这里没有匹配到命令:

我被困在这里一段时间了,我的命令在哪里?

visual-studio-code vscode-extensions
3个回答
12
投票

我刚才也遇到过这种情况。确保

engines.vscode
中的
package.json
与您正在运行的 vscode 版本匹配:

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

我猜生成器将使用可用的最新版本,但您可能尚未升级。我就是这样。


0
投票

@tacospice 准确地指出了。在

package.json
中,
engines.vscode
确定 VSCode 的最低版本。就我而言,
yo
创建了扩展模板,该模板设置的最低 VSCode 版本(1.74.0)比工作 VSCode(1.70.0)更新。用
Help -> About -> version
检查
package.json


0
投票

即使我面临同样的问题,vscode 版本不同 “引擎”: { “vscode”:“^1.73.0” },

© www.soinside.com 2019 - 2024. All rights reserved.