安装vscode web ide
环境搭建指南
1. 环境准备
- 操作系统: CentOS 7.9
- 包管理工具: Yarn
- 版本控制工具: Git
2. 依赖安装
2.1 安装 Node.js
# 移除旧版本 Node.jsyum remove nodejs
# 清理缓存yum clean all && yum makecache fast
# 安装编译工具yum install -y gcc-c++ make
# 添加 Node.js 14.x 源curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
# 安装 Node.jsyum install -y nodejs
2.2 安装 Git 和 Yarn
# 添加 Yarn 源curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
# 安装 Yarn 和 Gityum install yarn git -y
# 检查 Yarn 版本yarn --version 设置 Yarn 镜像源为淘宝镜像yarn config set registry https://registry.npm.taobao.org/yarn config get registry
3. 安装 VSCode Web IDE
3.1 获取代码
# 切换到 /opt 目录cd /opt
# 克隆最新版本的 VSCode 代码git clone --depth 1 https://github.com/microsoft/vscode.git
# 或者克隆指定版本的 VSCode 代码git clone --depth 1 --branch 1.45.1 https://github.com/microsoft/vscode.git
3.2 安装依赖
# 安装必要的开发包yum install pkgconfig libX11-devel libxkbfile-devel libsecret-devel -y
# 安装开发工具组yum groupinstall "Development Tools" -y
# 使用 Yarn 安装依赖yarn
3.3 清除缓存并重新安装依赖
# 清除 Yarn 缓存yarn cache clean
# 删除 node_modules 目录rm -rf node_modules/*
# 重新安装依赖yarn
3.4 启动 VSCode Web IDE
# 设置 Node.js 内存限制export NODE_OPTIONS="--max-old-space-size=4096"
# 启动 Yarn watchyarn watch
# 启动 VSCode Web IDEyarn web
3.5 常见问题处理
3.5.1 JavaScript 堆内存不足
如果遇到 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
错误,可以通过设置 NODE_OPTIONS
来增加内存限制:
export NODE_OPTIONS="--max-old-space-size=4096"
3.5.2 编译错误
如果遇到 [Release/obj.target/keymapping/src/keymapping.o] Error 1
错误,可能需要安装 gyp
:
pip3 install git+https://chromium.googlesource.com/external/gyp
3.5.3 安装 vscode-ripgrep
yarn cache cleanyarn add vscode-ripgrep
3.6 完成
至此,VSCode Web IDE 的安装和配置已完成,使用。