windows安装vscode服务端

Get-Command code -ErrorAction SilentlyContinue

Get-Command code-server -ErrorAction SilentlyContinue

三丰云系统检查完成。

现在在免费云服务器上开始安装 VS Code Server。我将使用官方推荐的安装脚本:

使用 Microsoft 官方的 VS Code CLI 安装方式:

Invoke-WebRequest -Uri "https://code.visualstudio.com/sha/download?build=stable\&os=cli-win32-x64" -OutFile vscode_cli.zip; Expand-Archive -Path vscode_cli.zip -DestinationPath .\vscode_cli -Force

下载成功!让我检查并设置环境变量:

.\vscode_cli\code.exe --version

现在让我将 VS Code CLI 添加到系统 PATH 并启动 tunnel 服务:

Environment\]::SetEnvironmentVariable("Path", $env:Path + ";D:\\vscodeserve\\vscode_cli", "User") Builder 我来帮你安装 VS Code Server。让我先了解一下当前环境,然后执行安装。 0/3 已完成 检查系统环境和现有安装 下载并安装 VS Code Server 验证安装是否成功 vscodeserve 在沙箱中 在终端查看 $ Get-Command code -ErrorAction SilentlyContinue (TraeAI-2) D:\\vscodeserve \[0:0\] $ vscodeserve 在沙箱中 在终端查看 $ Get-Command code-server -ErrorAction SilentlyContinue 1/3 已完成 检查系统环境和现有安装 下载并安装 VS Code Server 验证安装是否成功 系统检查完成。现在开始安装 VS Code Server。我将使用官方推荐的安装脚本: vscodeserve 在沙箱中 在终端查看 $ Invoke-WebRequest -Uri https://aka.ms/install-vscode-server/setup.ps1 -OutFile setup.ps1; ./setup.ps1 (some characters truncated)... ("\&"), 以将其作为字符串的一部分传递。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 393 * ... ndow.enableWebP?"webp":"jpg")};t.src="data:image/avif;base64,AAAAIGZ0 ... * ~ 参数列表中缺少参量。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 1343 * ... extContent="聽";(document.body\|\|document.documentElement).appendChild( ... . * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 表达式或语句中包含意外的标记"聽";(document.body\|\|document.documentElement).app endChild(n)}))}function h(n){var i="iotd-lite-bg",t=document.getElementById(i), r='#img_cont, #hp_top_cover { background-image: url("'+n+'") !important; }';t?t .textContent=r:(t=document.createElement("style"),t.id=i,t.textContent=r,docume nt.head.appendChild(t))}function e(n){window.iotdLightAppliedUrl=n;h(n);s();try {window.dispatchEvent(new CustomEvent("iotdLightApplied",{detail:n}))}catch(t){ }}function n(){window.iotdLightSource="network";o(function(n){var t=iotdUrl.rep lace(/.(jpg\|webp\|avif)/i,"."+n);typeof devicePixelRatio!="undefined"\&\&devicePi xelRatio\>=1.5\&\&(t=t.replace(/1920x1080/gi,"3840x2160"));u(t).then(function(n){w indow.iotdStaleBlobUrl="";e(n)})\["catch"\](function(){window.iotdStaleBlobUrl="" })})}function c(i){window.iotdLightSource="cache";var r=URL.createObjectURL(i); t.push®;u®.then(function(n){e(n)})["catch"](function%28%29%7Bn%28%29%7D)}function l(i){ var r=URL.createObjectURL(i);t.push®;window.iotdStaleBlobUrl=r;u®.then(func tion(t){e(t);n()})["catch"](function%28%29%7Bn%28%29%7D)}var r,t,f,i;!window.forceNoIOTD\&\&w indow.isIotdEnabled=0\&\&window.indexedDB\&\&(window.iotdLightDisplayed=!0,Perfor manceObserver.supportedEntryTypes.indexOf("element")!-1\&\&(r=new PerformanceOb server(function(n){n.getEntries().forEach(function(n){n.identifier==="TTVRCore. IOTD"\&\&(window\["TTVRCore.IOTD"\]=n.renderTime!0?n.renderTime:n.startTime,r.dis connect())})}),r.observe({type:"element",buffered:!0})),window.iotdLiteCleanup= function(){var n=document.getElementById("iotd-lite-bg");n\&\&n.remove()},t=\[\],wi ndow.addEventListener("beforeunload",function(){t.forEach(function(n){try{URL.r evokeObjectURL(n)}catch(t){}})},{once:!0}),f=!1,i=indexedDB.open("ImageCacheDB" ,2),i.οnerrοr=function(){return n()},i.onsuccess=function(){var u=i.result,t,r; if(!u.objectStoreNames.contains("IOTD")){n();return}t=u.transaction("IOTD","rea donly").objectStore("IOTD");r=t.get(iotdSsd);r.onsuccess=function(){var i=r.res ult,u;(i=null\|\|i=void 0?void 0:i.ImageBlob)\&\&i.Name=iotdName?c(i.ImageBlo b):(u=t.openCursor(null,"prev"),u.onsuccess=function(){var i,t=u.result;if(!t){ n();return}t.key\<=iotdSsd.substring(0,8)\&\&((i=t.value)=null\|\|i=void 0?void 0:i.ImageBlob)?l(t.value.ImageBlob):t["continue"]()})}})})();var sj_log=functio n(n,t,i){var r=window.directLog;r\&\&r(JSON.stringify(\[{T:n,FID:"CI",Name:t,Text: encodeURIComponent(i.replace(/"/g"。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3715 * ... \[{T:n,FID:"CI",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK ... * ~ 参数列表中缺少参量。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3718 * ... :n,FID:"CI",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"S ... * ~ 表达式或语句中包含意外的标记")"。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3719 * ... n,FID:"CI",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"SJ ... * ~ 表达式或语句中包含意外的标记")"。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3721 * ... ,FID:"CI",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"SJ" ... * ~ 一元运算符","后面缺少表达式。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3721 * ... ",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"SJ"}\]),0)}; * ~~~~~~~~ 表达式或语句中包含意外的标记"SDK:"SJ""。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3729 * ... ",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"SJ"}\]),0)}; * ~ 表达式或语句中包含意外的标记"}"。 所在位置 D:\\vscodeserve\\setup.ps1:2 字符: 3731 * ... ",Name:t,Text:encodeURIComponent(i.replace(/"/g,"")),SDK:"SJ"}\]),0)}; * ~ 表达式或语句中包含意外的标记")"。 并未报告所有分析错误。请更正报告的错误并重试。 + CategoryInfo : ParserError: (😃 \[\], ParseException + FullyQualifiedErrorId : AmpersandNotAllowed 看来官方脚本下载有问题。让我尝试另一种方法,使用 npm 来安装 code-server: vscodeserve 在沙箱中 在终端查看 $ npm install -g code-server npm : 无法将"npm"项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名 称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 5 * \& { npm install -g code-server } \| Out-Host; exit $LASTEXITCODE * ~~~ * CategoryInfo : ObjectNotFound: (npm:String) \[\], CommandNotFound Exception * FullyQualifiedErrorId : CommandNotFoundException 系统没有安装 npm。让我尝试使用 Microsoft 官方的 VS Code CLI 安装方式: vscodeserve 在沙箱中 在终端查看 $ Invoke-WebRequest -Uri "https://code.visualstudio.com/sha/download?build=stable\&os=cli-win32-x64" -OutFile vscode_cli.zip; Expand-Archive -Path vscode_cli.zip -DestinationPath .\\vscode_cli -Force 下载成功!让我检查并设置环境变量: vscodeserve\\vscode_cli vscodeserve 在沙箱中 在终端查看 $ .\\vscode_cli\\code.exe --version code 1.116.0 (commit 560a9dba96f961efea7b1612916f89e5d5d4d679) 现在让我将 VS Code CLI 添加到系统 PATH 并启动 tunnel 服务: vscodeserve 在沙箱中 在终端查看 $ \[Environment\]::SetEnvironmentVariable("Path", $env:Path + ";D:\\vscodeserve\\vscode_cli", "User") 2/3 已完成 检查系统环境和现有安装 下载并安装 VS Code Server 验证安装是否成功 vscodeserve 在沙箱中 在终端查看 $ .\\vscode_cli\\code.exe tunnel --help Create a tunnel that's accessible on vscode.dev from anywhere. Run `code tunnel --help` for more usage info Usage: code.exe tunnel \[OPTIONS\] \[COMMAND

Commands:

prune Delete all servers which are currently not running

kill Stops any running tunnel on the system

restart Restarts any running tunnel on the system

status Gets whether there is a tunnel running on the current machine

rename Rename the name of this machine associated with port forwarding service

unregister Remove this machine's association with the port forwarding service user

service (Preview) Manages the tunnel when installed as a system service,

help Print this message or the help of the given subcommand(s)

Options:

--install-extension <INSTALL_EXTENSION>

Requests that extensions be preloaded and installed on connecting servers

--server-data-dir <SERVER_DATA_DIR>

Specifies the directory that server data is kept in

--extensions-dir <EXTENSIONS_DIR>

Set the root path for extensions

--reconnection-grace-time <RECONNECTION_GRACE_TIME>

Reconnection grace time in seconds. Defaults to 10800 (3 hours)

-h, --help

Print help

ADVANCED OPTIONS:

--random-name Randomly name machine for port forwarding service

--no-sleep Prevents the machine going to sleep while this command runs

--name Sets the machine name for port forwarding service

--accept-server-license-terms If set, the user accepts the server license terms and the server will be started without a user prompt

GLOBAL OPTIONS:

--cli-data-dir <CLI_DATA_DIR> Directory where CLI metadata should be stored [env: VSCODE_CLI_DATA_DIR=]

--verbose Print verbose output (implies --wait)

--log Log level to use [possible values: trace, debug, info, warn, error, critical, off]

3/3 已完成

检查系统环境和现有安装

下载并安装 VS Code Server

验证安装是否成功

✅ VS Code Server 安装成功!

安装摘要

项目 详情 安装路径 D:\vscodeserve\vscode_cli\ 可执行文件 code.exe 版本 1.116.0 PATH 环境变量 已添加

使用方法

1. 启动 Tunnel 服务(推荐)

复制代码
.\vscode_cli\code.exe tunnel

第一次运行需要登录 Microsoft 或 GitHub 账号进行授权。

2. 常用命令

命令 说明 code tunnel 启动 tunnel 服务 code tunnel status 查看服务状态 code tunnel kill 停止服务 code tunnel restart 重启服务 code tunnel rename <新名称> 重命名机器

3. 连接方式

启动 tunnel 后,你会获得一个类似 https://vscode.dev/tunnel/\<机器名> 的链接,可以在任何地方通过浏览器访问。

4. 设置为系统服务(后台运行)

复制代码
.\vscode_cli\code.exe tunnel service install

我帮你启动 tunnel 服务

好的,我来帮你启动 VS Code Server 的 tunnel 服务。第一次运行需要登录 Microsoft 或 GitHub 账号进行授权。

vscodeserve

$ .\vscode_cli\code.exe tunnel

? How would you like to log in to Visual Studio Code? ›

❯ Microsoft Account

GitHub Account

Thought

🔐 VS Code Server 启动成功,需要登录授权

服务已经启动,现在需要你进行登录授权。终端显示了登录选项:

复制代码
? How would you like to log in to Visual Studio 
Code? ›
❯ Microsoft Account
  GitHub Account

授权步骤

  1. 选择登录方式 :使用上下箭头选择 Microsoft 账号或 GitHub 账号
  2. 按 Enter 确认 :选择后按 Enter 键
  3. 复制授权码 :会出现一个授权码
  4. 打开浏览器 :访问 https://vscode.dev/tunnel/login
  5. 粘贴授权码 :在网页中粘贴刚才复制的授权码
  6. 完成登录 :按照网页提示完成登录操作
  7. 返回终端 :授权成功后,终端会显示服务启动信息

启动后访问

授权成功后,你会获得一个类似 https://vscode.dev/tunnel/\<机器名> 的链接,可以在任何浏览器中访问。

相关推荐
学不思则罔1 小时前
ParallelStream并发陷阱解析
java·开发语言·windows
古怪今人2 小时前
项目和模块 一个目录下创建多个项目 IDEA Multi-Project Workspace插件
java·ide·intellij-idea
殇尘4 小时前
Docker + VSCode 搭建开发环境沙箱
vscode·docker·容器
2501_916007474 小时前
Xcode支持的编程语言、主要功能及使用指南
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
白小沫4 小时前
解决 TortoiseSVN 文件夹不显示图标的问题(Windows 10/11 通用)
windows·经验分享·笔记
shimly1234564 小时前
VSCode:“princexml“ is required to be installed
ide·vscode·编辑器
拙慕JULY5 小时前
AI 驱动的 Github 代码库理解工具——DeepWiki
ide·vscode·编辑器
2501_939998205 小时前
微软推送 Win11 2026 年 5 月累积更新(KB5089549)
windows
令狐少侠20115 小时前
workbuddy、openclaw能控制浏览器
windows·ai
AI砖家5 小时前
DeepSeek TUI 保姆级安装配置全指南 -Windows||macOS双平台全覆盖
服务器·前端·人工智能·windows·macos·ai编程·策略模式