在 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 倉庫。