在CentOS上升级Node.js版本,你可以选择使用NodeSource存储库或者NVM(Node Version Manager)
方法一:使用NodeSource存储库
sudo yum remove nodejs
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
yum
安装Node.js:sudo yum install -y nodejs
node -v
npm -v
方法二:使用NVM(Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bash_profile
nvm ls-remote
nvm install --lts
nvm use --lts
node -v
npm -v
注意:使用NVM时,每个用户都需要单独安装和激活NVM。如果你在系统范围内升级Node.js,建议使用NodeSource存储库方法。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>