操作系统

CentOS 上使用 `yum` 安装 Node.js

By karp 779 Views 3 MIN READ 0 Comments

在 CentOS 上使用 yum 安装 Node.js 非常简单。可以按照以下步骤进行:

1. 添加 NodeSource 仓库

NodeSource 提供了 Node.js 的官方仓库。首先,添加你需要的 Node.js 版本仓库,例如 Node.js 16.x:

curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -

2025-05-14T01:12:03.png

2. 安装 Node.js

接下来,使用 yum 安装 Node.js:

sudo yum install -y nodejs

2025-05-14T01:13:09.png

3. 验证安装

安装完成后,检查 Node.js 和 npm 版本以确认安装成功:

# node -v
v16.20.2

# npm -v
8.19.4

4. 更新 npm(可选)

如果需要更新 npm 到最新版本,可以使用以下命令:

sudo npm install -g npm@latest

本文由 karp 原创

采用 CC BY-NC-SA 4.0 协议进行许可

转载请注明出处:https://www.ikarp.top/index.php/archives/789.html

标签: centos

0 评论