要在Debian系统中升级Node.js版本,您可以使用NodeSource存储库或NVM(Node Version Manager)。下面是使用这两种方法的详细步骤:
方法1:使用NodeSource存储库
sudo apt-get remove --purge nodejs
sudo apt-get autoremove
sudo apt-get update
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
node --version
npm --version
方法2:使用NVM(Node Version Manager)
sudo apt-get remove --purge nodejs
sudo apt-get autoremove
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 14
nvm use 14
node --version
npm --version
现在,您已经成功地在Debian系统上升级了Node.js版本。如果您想要切换到其他版本,只需使用nvm use <version>
命令即可。