ubuntu

Ubuntu如何安装Node.js

小樊
48
2025-03-14 05:02:08
栏目: 编程语言

在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。

0
看了该问题的人还看了