环境搭建
安装以下环境:
-
Git

-
Node.JS, x64, version
>=18.15.x and <19

-
Yarn 1, version
>=1.10.1 and <2, follow the installation guide

-
Python

方法1:
npm install --global --production windows-build-tool
方法2:使用Visual Studio Build Tools.exe
最新版本为2022版本,但是在该版本下,编译过程中报错,所以采用2019版本

此处参考:windows 下 node 原生编译环境趟坑 - 白一梓的文章 - 知乎
简单来说
vs build tools 2017 版本,地址格式是
https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
如果下载 2019 版本,只需要将链接中的 rel 参数改为 16 即可;下载 2022 版本,rel 参数为 17。
本次安装采用的是2019版本。



编译和运行
-
获取源码
git clone https://github.com/microsoft/vscode.git
-
下载依赖
cd vscode
yarn
此步骤问题较多,可参考问题记录解决。
依赖下载完成,如下图:

-
编译源码
.\scripts\code.bat
编译完成如下

编译后得到code-oss:

问题记录
问题1:

错误原因:国外源链接速度慢,导致无法下载依赖;在科学上网的前提下也会出现该错误
解决方法:使用国内源替换npm官方源
替换国内源:
npm config set registry https://registry.npmmirror.com
查看当前源:
npm config get registry

yarn同理:

并设置ElECTRON_MIRROR:

yarn config set ELECTRON_MIRROR https://registry.npmmirror.com/-/binary/electron/
打开项目下的yarn.lock文件

原路径为:https://registry.yarnpkg.com
替换为:https://registry.npmmirror.com
问题2:
yarn install failed :vscode-ripgrep: Command failed.

错误原因:损坏的vscode-ripgrep安装导致了这个问题。
解决方法:找到C盘用户路径下的~\AppData\Local\Temp\vscode-repgrep-cache*文件夹,删除这个文件夹,再次尝试yarn
参考链接:
https://github.com/microsoft/vscode/wiki/How-to-Contribute
本文详细描述了如何在Windows系统上安装必要的开发环境,如Git、Node.js、Yarn和VisualStudioBuildTools,并指导如何解决编译VSCode时遇到的问题,包括网络依赖下载问题和损坏的vscode-ripgrep安装问题。
1511

被折叠的 条评论
为什么被折叠?



