安裝
code-server的安裝方法支很多種,通用性比較強的方法是使用docker和npm,這里先以docker為例
使用docker安裝code-server
使用該命令運行容器后訪問-p 127.0.0.1:8080:8080
所指定的8080
端口查看運行結果,控制台將輸出所需的秘鑰
# This will start a code-server container and expose it at http://127.0.0.1:8080.
# It will also mount your current directory into the container as `/home/coder/project`
# and forward your UID/GID so that all file system operations occur as your user outside
# the container.
#
# Your $HOME/.config is mounted at $HOME/.config within the container to ensure you can
# easily access/modify your code-server config in $HOME/.config/code-server/config.json
# outside the container.
mkdir -p ~/.config
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
-v "$HOME/.config:/home/coder/.config" \
-v "$PWD:/home/coder/project" \
-u "$(id -u):$(id -g)" \
-e "DOCKER_USER=$USER" \
codercom/code-server:latest
如果需要更該配置文件,請在宿主機的~/.config
目錄中修改配置即可
使用npm安裝code-server
coder server 使用與 VSCode 的 Electron 相同的 Node.js 主要版本,目前是 14.x
npm i -g code-server
獨立版本安裝
直接到官網下載您系統的獨立版本,隨后您可以參考如下步驟進行安裝
tar -xzvf ./<您所下載的獨立版本的文件>
./<解壓后的路徑>/code-server
此時在控制台便能看到code-server的輸出,您也可以參考如下教程進行簡單的配置