因为在FreeBSD下安装Code Server 失败,所以到linux下去安装。所用的机器为FreeBSD下的Ubuntu虚拟机主机,ip192.168.1.12.
安装node
安装node参考这个文档:https://skywalk.blog.csdn.net/article/details/149314275
二进制安装
先从网站下载node .xz文件
解开xz文件
tar -xvf node.xz
然后把路径加上就行了。
export PATH=/home/skywalk/node-v24.11.1-linux-x64/bin:$PATH
后面还尝试了安装npm新版本,我也不知道这样做对不对:
root@ubjail1:~/node-v24.11.1-linux-x64/bin# ./node npm install npm
added 1 package in 10s
25 packages are looking for funding
run `npm fund` for details
npm notice
npm notice New patch version of npm available! 11.6.2 -> 11.6.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.6.3
npm notice To update run: npm install -g npm@11.6.3
npm notice
root@ubjail1:~/node-v24.11.1-linux-x64/bin# ./node npm install -g npm@11.6.3
removed 9 packages, and changed 54 packages in 8s
25 packages are looking for funding
run `npm fund` for details
用普通用户装node就这么简单
cd ~
tar -xvf /tmp/node-v24.11.1-linux-x64.tar.xz
export PATH=/home/skywalk/node-v24.11.1-linux-x64/bin:$PATH
也可以选择:
一句话安装node
# 下载并安装 nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# 代替重启 shell
\. "$HOME/.nvm/nvm.sh"
# 下载并安装 Node.js:
nvm install 24
# 验证 Node.js 版本:
node -v # Should print "v24.11.1".
# 验证 npm 版本:
npm -v # Should print "11.6.2".
不过近期github有时候会抽风,这个一句话安装node有可能会失败。
安装code server
也是一句话安装:
curl -fsSL --http1.1 https://code-server.dev/install.sh | sh
安装完成:
curl -fsSL --http1.1 https://code-server.dev/install.sh | sh
Ubuntu 22.04 LTS
Installing v4.106.2 of the amd64 deb package from GitHub.
+ mkdir -p ~/.cache/code-server
+ curl -#fL -o ~/.cache/code-server/code-server_4.106.2_amd64.deb.incomplete -C - https://github.com/coder/code-server/releases/download/v4.106.2/code-server_4.106.2_amd64.deb
######################################################################## 100.0%
+ mv ~/.cache/code-server/code-server_4.106.2_amd64.deb.incomplete ~/.cache/code-server/code-server_4.106.2_amd64.deb
+ sudo dpkg -i ~/.cache/code-server/code-server_4.106.2_amd64.deb
[sudo] password for skywalk:
Sorry, try again.
[sudo] password for skywalk:
Selecting previously unselected package code-server.
(Reading database ... 46336 files and directories currently installed.)
Preparing to unpack .../code-server_4.106.2_amd64.deb ...
Unpacking code-server (4.106.2) ...
Setting up code-server (4.106.2) ...
deb package has been installed.
To have systemd start code-server now and restart on boot:
sudo systemctl enable --now code-server@$USER
Or, if you don't want/need a background service you can run:
code-server
Deploy code-server for your team with Coder: https://github.com/coder/coder
从这里拿到密码
/home/skywalk/.config/code-server/config.yaml
浏览器打开8080端口:
输入token,这个token可以从文件.config/code-server/config.yaml拿到,文件内容类似
bind-addr: 127.0.0.1:8080
auth: password
password: 813545bf9adb121b199374xx
cert: false
VSCode的远程编辑页面就出来了:

同时,用Comate IDE和CodeBuddy等都可以远程连上来了!
总结
Code server在Linux下非常好安装,但是在FreeBSD下可能会有较多的波折。
安装好Code server后,VSCode家族的编程软件都可以在"远程资源管理器"里添加远程资源。
也可以通过8080端口,使用web远程打开!
调试
安装报错curl: (16) Error in the HTTP2 framing layer
curl -fsSL https://code-server.dev/install.sh | sh
curl: (16) Error in the HTTP2 framing layer
尝试用http1.1协议
curl -fsSL --http1.1 https://code-server.dev/install.sh | sh
ok 了