Vscode插件编写(1)-启动一个Hello World项目

137 阅读1分钟

目录

  • 1.启动一个Hello World项目
  • 2.踩坑
  • 3.参考资料

1.启动一个Hello World项目

  • 安装模板生成器
npm install --global yo generator-code
  • 启动一个模板
yo code
  • 按照以下配置进行选择
# ? What type of extension do you want to create? New Extension (TypeScript)
# ? What's the name of your extension? HelloWorld
### Press <Enter> to choose default for all options below ###

# ? What's the identifier of your extension? helloworld
# ? What's the description of your extension? LEAVE BLANK
# ? Initialize a git repository? Yes
# ? Bundle the source code with webpack? No
# ? Which package manager to use? npm

# ? Do you want to open the new folder with Visual Studio Code? Open with `code`
  • 打开src/extension.ts并按F5,在新打开的vscode窗口当中按option+command+P

2.踩坑

完成以上步骤,你想象当中你会成功打开一个hello world命令,但是实际的你,很有可能搜索不到这个命令。

想象之中:
image.png 实际:

image.png

这是由于vscode项目所依赖的vscode的版本有可能高于本地的vscode版本。举例说明:

image.png

所以要把package.json当中的版本统一改为^1.85.1(本地的版本)

3.参考资料

4.随便聊聊

祝平行世界里的你我,早安,午安,晚安。