Skip to content

安装vscode web ide

环境搭建指南

1. 环境准备

  • 操作系统: CentOS 7.9
  • 包管理工具: Yarn
  • 版本控制工具: Git

2. 依赖安装

2.1 安装 Node.js

Terminal window
# 移除旧版本 Node.js
yum 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.js
yum install -y nodejs

2.2 安装 Git 和 Yarn

Terminal window
# 添加 Yarn 源
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
# 安装 Yarn 和 Git
yum 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 获取代码

Terminal window
# 切换到 /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 安装依赖

Terminal window
# 安装必要的开发包
yum install pkgconfig libX11-devel libxkbfile-devel libsecret-devel -y
# 安装开发工具组
yum groupinstall "Development Tools" -y
# 使用 Yarn 安装依赖
yarn

3.3 清除缓存并重新安装依赖

Terminal window
# 清除 Yarn 缓存
yarn cache clean
# 删除 node_modules 目录
rm -rf node_modules/*
# 重新安装依赖
yarn

3.4 启动 VSCode Web IDE

Terminal window
# 设置 Node.js 内存限制
export NODE_OPTIONS="--max-old-space-size=4096"
# 启动 Yarn watch
yarn watch
# 启动 VSCode Web IDE
yarn web

3.5 常见问题处理

3.5.1 JavaScript 堆内存不足

如果遇到 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 错误,可以通过设置 NODE_OPTIONS 来增加内存限制:

Terminal window
export NODE_OPTIONS="--max-old-space-size=4096"

3.5.2 编译错误

如果遇到 [Release/obj.target/keymapping/src/keymapping.o] Error 1 错误,可能需要安装 gyp

Terminal window
pip3 install git+https://chromium.googlesource.com/external/gyp

3.5.3 安装 vscode-ripgrep

Terminal window
yarn cache clean
yarn add vscode-ripgrep

3.6 完成

至此,VSCode Web IDE 的安装和配置已完成,使用。