如何在 Debian 上安装 Node.js

如何在 Debian 上安装 Node.js

debian 上安装 Node.JS 的方式有多种,本文将介绍两种常用方法:通过包管理器(APT)以及通过 NodeSource 仓库进行安装。

方法一:通过包管理器(APT)安装

  1. 启动终端。
  2. 首先,更新软件包列表:
sudo apt update
  1. 接着,安装 Node.js 和 npm(Node.js 的包管理工具):
sudo apt install nodejs npm
  1. 安装完毕后,验证 Node.js 和 npm 是否安装成功:
node --version npm --version

方法二:通过 NodeSource 仓库安装

  1. 打开终端。
  2. 根据您的需求,选择要安装的 Node.js 版本。例如,若想安装最新的 LTS(长期支持)版本,执行以下命令:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

如果您希望安装特定版本,例如 14.x,运行:

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
  1. 添加 NodeSource 仓库并安装 Node.js 和 npm:
sudo apt-get install -y nodejs
  1. 安装完成后,检查 Node.js 和 npm 是否已正确安装:
node --version npm --version

至此,您已在 Debian 系统上成功安装了 Node.js 和 npm。现在,您可以利用它们来运行和部署您的 Node.js 应用程序了。

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享