在 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 中的版本号。