在 Debian 上安装 Node.js 的方法有多种,以下是其中两种常用的方法:
方法一:使用包管理器(推荐)
打开终端。
更新软件包列表:
sudo apt update
sudo apt install nodejs npm
node --version
npm --version
方法二:使用 NodeSource 仓库
打开终端。
安装必要的软件包以添加 NodeSource 仓库:
sudo apt install curl software-properties-common
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt update
sudo apt install nodejs npm
node --version
npm --version
这两种方法都会在 Debian 系统上安装 Node.js 和 npm。使用包管理器安装的方法会安装一个较旧的版本,而使用 NodeSource 仓库的方法可以安装最新的 LTS 版本。根据你的需求选择合适的方法进行安装。