在 CentOS 上升級 Node.js 的推薦方法是使用 NodeSource 存儲庫
sudo yum remove nodejs
sudo yum install -y curl
lts/*
替換為所需的版本,例如 14.x
或 16.x
。curl -sL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo yum install -y nodejs
node --version
npm --version
現在,您已經在 CentOS 上升級了 Node.js。如果您需要更新到其他版本,只需重復上述步驟并更改 setup_lts.x
中的版本號。