要在Debian上更新Node.js版本,您可以使用NodeSource存储库或nvm(Node Version Manager)
方法1:使用NodeSource存储库
sudo apt-get remove --purge nodejs sudo apt-get autoremove sudo apt-get update sudo apt-get install curl software-properties-common curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs node -v npm -v 方法2:使用nvm(Node Version Manager)
sudo apt-get remove --purge nodejs sudo apt-get autoremove curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash ~/.bashrc、~/.bash_profile或~/.zshrc文件中:export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm source ~/.bashrc nvm install node nvm use node node -v npm -v 现在,您已经成功更新了Debian上的Node.js版本。如果您想要切换到其他版本,只需使用nvm use <version>命令。