Skip to content

远程服务器 8.153.84.140 安装 Node.js 和 Cline 文档

安装日期:2026-08-15
服务器:8.153.84.140(阿里云)
操作系统:CentOS 7 (Core)
内核版本:3.10.0-1160.119.1.el7.x86_64
连接方式:SSH 密钥登录(root 用户)


一、安装结果总览

组件版本安装路径
Node.jsv20.20.2/usr/local/bin/node
npm10.8.2/usr/local/bin/npm
Cline3.0.55/usr/local/bin/cline

二、安装步骤

2.1 SSH 连接服务器

bash
ssh -o StrictHostKeyChecking=no root@8.153.84.140

2.2 安装 Node.js(使用 glibc-217 兼容版本)

由于 CentOS 7 的 glibc 版本为 2.17,官方 Node.js 20 要求 glibc >= 2.28,因此需要使用 Node.js 的 unofficial builds。

方法:从 unofficial-builds 下载兼容版本

bash
# 下载(由于服务器网络慢,此步可能耗时较长)
cd /tmp
curl -fsSL -o node.tar.xz \
  https://unofficial-builds.nodejs.org/download/release/v20.20.2/node-v20.20.2-linux-x64-glibc-217.tar.xz

# 解压
tar -xf node.tar.xz

# 安装到 /usr/local
cp -rf node-v20.20.2-linux-x64-glibc-217/* /usr/local/

# 清理临时文件
rm -rf node-v20.20.2-linux-x64-glibc-217 node.tar.xz

# 验证
node --version   # 期望: v20.20.2
npm --version    # 期望: 10.8.2

加速方案:本地下载后 scp 传输(推荐)

bash
# 在本地机器执行
curl -fsSL -o /tmp/node-v20-glibc217.tar.xz \
  https://unofficial-builds.nodejs.org/download/release/v20.20.2/node-v20.20.2-linux-x64-glibc-217.tar.xz

# scp 传输到远程服务器
scp -o StrictHostKeyChecking=no /tmp/node-v20-glibc217.tar.xz root@8.153.84.140:/tmp/node.tar.xz

# 在远程服务器上解压安装
ssh root@8.153.84.140 'cd /tmp && tar -xf node.tar.xz && cp -rf node-v20.20.2-linux-x64-glibc-217/* /usr/local/ && rm -rf node-v20.20.2-linux-x64-glibc-217 node.tar.xz'

# 清理本地临时文件
rm -f /tmp/node-v20-glibc217.tar.xz

2.3 配置 npm 淘宝镜像(加速国内访问)

bash
npm config set registry https://registry.npmmirror.com

# 验证
npm config get registry
# 期望输出: https://registry.npmmirror.com

2.4 安装 Cline

bash
# 前台安装(网络正常时)
npm install -g cline

# 后台安装(网络较慢时)
nohup npm install -g cline > /tmp/cline_install.log 2>&1 &
# 查看安装进度
tail -f /tmp/cline_install.log

# 验证
which cline        # 期望: /usr/local/bin/cline
cline --version    # 期望: 3.0.55

三、遇到的问题及解决方案

问题 1:NodeSource 安装的 Node.js 20 依赖 glibc >= 2.28

现象:

bash
# 使用 NodeSource 官方方式安装
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
yum install nodejs -y

报错信息:

Error: Package: 2:nodejs-20.20.2-1nodesource.x86_64 (nodesource-nodejs)
  Requires: glibc >= 2.28
  Installed: glibc-2.17-326.el7_9.3.x86_64 (@updates)

Error: Package: 2:nodejs-20.20.2-1nodesource.x86_64 (nodesource-nodejs)
  Requires: libm.so.6(GLIBC_2.27)(64bit)

Error: Package: 2:nodejs-20.20.2-1nodesource.x86_64 (nodesource-nodejs)
  Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)

Error: Package: 2:nodejs-20.20.2-1nodesource.x86_64 (nodesource-nodejs)
  Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)

Error: Package: 2:nodejs-20.20.2-1nodesource.x86_64 (nodesource-nodejs)
  Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)

原因: CentOS 7 的 glibc 版本为 2.17,而 NodeSource 提供的 Node.js 20 RPM 包要求 glibc >= 2.28。CentOS 7 无法升级 glibc 到该版本。

解决方案: 使用 Node.js Unofficial Builds 提供的 glibc-217 兼容版本,以 tar.xz 方式手动安装到 /usr/local/


问题 2:远程服务器下载 Node.js 速度极慢/超时

现象: 在远程服务器上通过 curl 下载 Node.js 包,速度仅约 100KB/s,26MB 文件下载超过 5 分钟仍未完成,SSH 命令多次超时。

原因: 远程服务器(阿里云)到 unofficial-builds.nodejs.org 的网络带宽有限。

解决方案: 在本地机器下载文件(速度正常),然后通过 scp 传输到远程服务器。

bash
# 本地下载(约 26MB)
curl -fsSL -o /tmp/node.tar.xz \
  https://unofficial-builds.nodejs.org/download/release/v20.20.2/node-v20.20.2-linux-x64-glibc-217.tar.xz

# scp 传输
scp /tmp/node.tar.xz root@8.153.84.140:/tmp/node.tar.xz

问题 3:npm install 全局安装超时

现象: npm install -g cline 命令在 30 秒内未完成,SSH 命令超时退出。

原因: npm 默认 registry(registry.npmjs.org)在国内访问较慢。

解决方案:

  1. 设置淘宝 npm 镜像加速:

    bash
    npm config set registry https://registry.npmmirror.com
  2. 使用后台安装避免 SSH 超时:

    bash
    nohup npm install -g cline > /tmp/cline_install.log 2>&1 &

问题 4:Cline TLS 证书警告

现象:

[cline] Node 20.20.2 cannot read the OS trust store (needs >= 22.15);
corporate or self-signed CAs may fail TLS. Upgrade Node or set NODE_EXTRA_CA_CERTS.

原因: Cline 依赖 @ai-sdk/gateway,该包要求 Node >= 22 才能正确读取系统信任证书存储。Node 20 虽然可以运行 Cline,但在处理某些 TLS 证书时可能有问题。

影响: 对于普通使用场景(如连接 Anthropic API、OpenRouter 等)不影响功能。仅在使用企业自签名 CA 证书的环境中可能出现 TLS 错误。

解决方案(如需彻底解决):

  • 方案 A:升级 Node.js 到 >= 22.15(需要升级系统 glibc 或迁移到更新的 OS)
  • 方案 B:设置环境变量指定证书:
    bash
    export NODE_EXTRA_CA_CERTS=/etc/pki/tls/certs/ca-bundle.crt
  • 方案 C:当前版本可正常使用,暂不处理

问题 5:部分依赖包警告 Node 版本不兼容

现象:

npm warn EBADENGINE   package: '@ai-sdk/gateway@4.0.52',
npm warn EBADENGINE   required: { node: '>=22' },
npm warn EBADENGINE   current: { node: 'v20.20.2', npm: '10.8.2' }

原因: @ai-sdk/gateway 包声明需要 Node >= 22,但当前安装的是 Node 20。

影响: 仅为警告(EBADENGINE),包仍然会安装成功。324 个依赖包全部安装完毕。Cline 核心功能不受影响。


四、服务器环境配置摘要

操作系统:    CentOS Linux 7 (Core)
内核版本:    3.10.0-1160.119.1.el7.x86_64
架构:        x86_64
glibc:       2.17-326.el7_9.3
Node.js:     v20.20.2 (unofficial-builds, glibc-217 compatible)
npm:         10.8.2
npm镜像:     https://registry.npmmirror.com
Cline:       3.0.55
Node路径:    /usr/local/bin/node
npm路径:     /usr/local/bin/npm
Cline路径:   /usr/local/bin/cline
SSH连接:     ssh root@8.153.84.140 (密钥认证)

五、常用维护命令

bash
# 检查 Node.js 和 Cline 版本
node --version && npm --version && cline --version

# 更新 Cline
npm update -g cline

# 卸载 Cline
npm uninstall -g cline

# 查看全局安装的包
npm list -g --depth=0

# 清理 npm 缓存
npm cache clean --force

# 查看 Cline 帮助
cline --help

六、参考链接