官方文档:https://github.com/Microsoft/vscode/wiki/How-to-Contribute

安装软件

  1. git

  2. nodejs

    版本需>=10.x<=12.xapt安装默认版本为8

    1
    2
    3
    4
    5
    sudo apt-get install nodejs
    sudo apt-get install npm
    sudo npm install npm -g
    sudo npm install -g n
    sudo n 12.16.1
  3. yarn

    官方安装文档:
    https://classic.yarnpkg.com/en/docs/install#debian-stable

    1
    2
    3
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt update && sudo apt install yarn
  4. python

    必须是2.7,不支持Python3

  5. make

  6. pkg-config

  7. libx11-dev

  8. libxkbfile-dev

  9. libsecret-1-dev

下载vscode源码

1
git clone https://github.com/microsoft/vscode.git

安装cnpm

国内使用npm太慢,简易使用cnpm。(修改npm源依旧会下载失败)

编译vscode

1
2
cd vscode
yarn

会遇到各种错误

  1. 下载失败/解压失败

    此时,会显示下载地址,下载到哪里,解压到哪里
    手动下载到指定目录,并加压到指定地点,文件夹不存在时需创建

  2. 编译错误

    找到编译错误的组件,使用npm卸载后,cnpm安装
    常见错误组件有vscode-ripgrepnode-gypelectron

  3. 卡在electron

    1. 进入node_moduls/electron/

    2. package.js中找到下载地址,并下载,一般为_resolved

    3. 创建path.txt,写入electron(Windows版本是electron.exe)

    4. 将安装包解压到dist文件夹下

    5. 执行

      1
      node install.js

重新运行编译

watch

1
yarn watch

会在watch-client执行较长时间

Finished compilation with 0 errors时,可以直接退出

运行

1
yarn web --host IP --port 端口号