在 Debian 系统中更新 Node.js 版本,你可以选择使用包管理器(如 apt)或者使用 NodeSource 仓库
方法一:使用包管理器(apt)
sudo apt update
sudo apt install nodejs npm
node --version
npm --version
请注意,使用 apt 安装的 Node.js 版本可能不是最新的。如果你需要最新版本,请考虑使用 NodeSource 仓库。
方法二:使用 NodeSource 仓库
sudo apt-get purge nodejs npm
sudo apt-get install curl software-properties-common
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
如果你需要安装特定版本的 Node.js,可以将 setup_lts.x 替换为 setup_x.x,其中 x.x 是你需要的版本号。
sudo apt update
sudo apt install nodejs npm
node --version
npm --version
现在,你已经成功更新了 Debian 系统上的 Node.js 版本。如果你需要切换到其他版本,只需重复上述步骤并添加相应版本的 NodeSource 仓库。