Ubuntu如何安装Node.js

635
2025/3/14 6:31:57
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Ubuntu上安装Node.js有多种方法,以下是两种常用的安装方式:

使用NodeSource PPA安装

  1. 添加NodeSource PPA
sudo apt update
sudo apt install curl -y
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
  1. 安装Node.js和npm
sudo apt install nodejs -y
  1. 验证安装
node -v
npm -v

使用APT包管理器安装

  1. 更新系统软件包列表
sudo apt update
  1. 安装Node.js和npm
sudo apt install nodejs npm -y
  1. 验证安装
node -v
npm -v

请注意,使用APT包管理器安装的版本可能不是最新的LTS版本。如果需要安装最新版本的Node.js,推荐使用NodeSource PPA。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: Ubuntu设置串口输出的步骤是什么