在 CentOS 系统中,您可以使用 Node Version Manager(NVM)来轻松地切换 Node.js 版本。以下是使用 NVM 安装和切换 Node.js 版本的步骤:
sudo yum install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm --version
nvm ls-remote
nvm install --lts
nvm use <version>
将 <version> 替换为您刚刚安装的版本,例如:
nvm use 14.18.1
node --version
现在,您已经成功地在 CentOS 系统中使用 NVM 切换了 Node.js 版本。如果您想要切换到另一个版本,只需重复步骤 5 和 6。