Debian如何更新Node.js到最新版本

要在Debian上将Node.js更新到最新版本,您可以使用NodeSource存储库

  1. 首先,删除现有的Node.js和npm:
sudo apt-get remove --purge nodejs npm
  1. 安装必要的软件包以添加NodeSource存储库:
sudo apt-get install curl software-properties-common
  1. 添加NodeSource存储库。您可以选择要安装的Node.js版本。例如,要安装最新的LTS(长期支持)版本,请运行:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

如果您想安装特定版本(例如14.x),请将setup_lts.x替换为setup_14.x

  1. 添加存储库后,使用以下命令更新软件包列表:
sudo apt-get update
  1. 现在,您可以安装最新版本的Node.js和npm:
sudo apt-get install -y nodejs
  1. 安装完成后,验证Node.js和npm是否已成功更新到最新版本:
node --version
npm --version

这将显示已安装的Node.js和npm的版本。如果您想安装其他版本的Node.js,只需重复上述步骤并更改存储库URL即可。

Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.259