在Debian系统上进行Node.js版本管理,通常推荐使用 Node Version Manager (NVM)。以下是使用NVM在Debian系统上进行Node.js版本管理的详细步骤:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
或者
source ~/.bash_profile
nvm --version
nvm list available
nvm install 14.16.0
nvm use 14.16.0
node -v
nvm list
nvm uninstall 14.16.0
除了NVM,还可以使用NodeSource来安装特定版本的Node.js。以下是步骤:
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
sudo apt-get install -y nodejs-legacy