ubuntu 升级 nodejs 版本

为了安装 claude code 需要升级 node

1. 彻底移除旧版本(避免冲突):
sudo apt-get remove --purge nodejs npm
sudo apt-get autoremove

2. 添加 NodeSource 仓库(以 Node.js 20.x LTS 为例):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
如果想安装其他版本,可以将 20.x 替换为 18.x、22.x 或 lts.x。

3. 安装新版本 Node.js:
sudo apt-get install -y nodejs

若是下载较慢可以临时使用代理:
sudo apt-get -o Acquire::http::Proxy="http://127.0.0.1:7897" \
-o Acquire::https::Proxy="http://127.0.0.1:7897" \
-o Acquire::Queue-Mode=access \
-o Acquire::http::Dl-Limit=0 \
install -y nodejs

posted @ 2026-03-24 14:39  口嗨养生博  阅读(15)  评论(0)    收藏  举报