google-cloud-platform - 在 gcp 云 shell 上运行代码服务器在预览时会出错
问题描述
我正在尝试在 gcp 云外壳上运行代码服务器。我下载了以下版本
https://github.com/cdr/code-server/releases/download/v3.9.2/code-server-3.9.2-linux-amd64.tar.gz我认为是正确的,提取了内容并跑了
code-server --auth none
这给出了以下输出
[2021-04-06T00:53:21.728Z] info code-server 3.9.2 109d2ce3247869eaeab67aa7e5423503ec9eb859
[2021-04-06T00:53:21.730Z] info Using user-data-dir ~/.local/share/code-server
[2021-04-06T00:53:21.751Z] info Using config file ~/.config/code-server/config.yaml
[2021-04-06T00:53:21.751Z] info HTTP server listening on http://127.0.0.1:8080
[2021-04-06T00:53:21.751Z] info - Authentication is disabled
[2021-04-06T00:53:21.751Z] info - Not serving HTTPS
现在,当我尝试Web Preview -> preview on port 8080
什么都没发生时,我只是得到一个空白屏幕,在代码控制台上我看到以下错误
2021-04-06T00:50:04.470Z] 错误 vscode 握手超时 {"token":"e9b80ff7-10f9-4089-8497-b98688129452"}
我不确定我需要在这里做什么?
解决方案
在 cloud shell 编辑器中,创建一个扩展名为 .sh 的文件,并使用以下步骤安装代码服务器:
export VERSION=`curl -s https://api.github.com/repos/cdr/code-server/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'` wget https://github.com/cdr/code-server/releases/download/v3.10.2/code-server-3.10.2-linux-amd64.tar.gz tar -xvzf code-server-3.10.2-linux-amd64.tar.gz cd code-server-3.10.2-linux-amd64
使用终端运行 vscode.sh 文件:
./vscode.sh
如果出现警告“权限被拒绝”,请键入
chmod +x vscode.sh
然后再次继续运行该文件。要导航到文件夹:
cd code-server-3.10.2-linux-amd64/
要导航到垃圾箱:
cd bin/
启动服务器:
./code-server --auth none --port 8080
现在,您可以通过使用 web preview->preview on port 8080 选项或终端中的 HTTP 服务器链接在浏览器中查看 VSCode IDE。
推荐阅读
- python - Spyder 4.1.4 似乎“压扁”了一些行以及一个混乱的行号和一个不相关的错误
- postgresql - Zalando postgres 操作员在 k8s 中从外部访问集群
- c - 如何在 lex 中对无效标识符进行规则?
- javascript - JS 性能:使用对象文字 VS 存储在变量中的对象的函数调用
- rest - 有没有办法使用其 REST API 从 JBPM 7 获取完整的任务
- search - 问:Atom 编辑器上的大写/小写搜索问题
- python - 尝试使用 Sendinblue/Sendgrid SMTP 发送忘记密码的电子邮件时出现 SMTPRefused 错误
- git - Git:与 Funtoo 钥匙串集成
- java - Java 找不到文件作为本机代码颤动
- android - 尝试在 Android Studio 中运行时出现 AVD 错误