如何快速安装Node.js:NodeSource二进制分发版完整指南

【免费下载链接】distributions NodeSource Node.js Binary Distributions 【免费下载链接】distributions 项目地址: https://gitcode.com/gh_mirrors/di/distributions

NodeSource Node.js Binary Distributions是一个专注于提供高效、可靠Node.js安装方案的开源项目,帮助开发者在各种Linux系统上轻松部署不同版本的Node.js环境。无论是开发环境搭建还是生产系统部署,这个工具都能提供稳定的支持。

📋 什么是NodeSource分发版?

NodeSource提供的二进制分发版是经过优化的Node.js安装包,支持Debian/Ubuntu和Enterprise Linux(RPM)等主流Linux系统。与系统自带的包管理器相比,它具有以下优势:

  • 提供最新的Node.js版本,包括LTS和Current版本
  • 简化的安装流程,通过脚本自动配置
  • 支持多种架构(amd64、arm64等)
  • 包含N|Solid企业级运行时选项

🔍 支持的系统版本

Debian/Ubuntu系统

系统版本 Node 18x Node 20x Node 22x Node 24x
Ubuntu 20.04
Ubuntu 22.04
Debian 10
Debian 11

Enterprise Linux系统

系统版本 Node 18x Node 20x Node 22x Node 23x
Redhat 8
Redhat 9
Fedora >=29
Amazon Linux 2023

🚀 快速安装步骤(Debian/Ubuntu)

安装Node.js 24.x(当前最新版)

  1. 首先确保安装了curl工具:
sudo apt install -y curl
  1. 下载并运行安装脚本:
curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
  1. 安装Node.js:
sudo apt install -y nodejs
  1. 验证安装是否成功:
node -v

安装LTS版本(推荐生产环境)

如果需要安装长期支持版本(目前为22.x),只需将上述步骤中的setup_24.x替换为setup_lts.x

curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs

📦 RPM系统安装指南(CentOS/RHEL/Fedora)

以Node.js 23.x为例:

  1. 安装curl(如果尚未安装):
sudo yum install -y curl
  1. 下载并执行安装脚本:
curl -fsSL https://rpm.nodesource.com/setup_23.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
  1. 安装Node.js:
sudo yum install -y nodejs
  1. 验证安装:
node -v

🔧 卸载方法

如需完全卸载Node.js或N|Solid,可以使用以下命令:

Debian/Ubuntu系统

# 卸载Node.js
sudo apt purge nodejs &&\
sudo rm -r /etc/apt/sources.list.d/nodesource.list &&\
sudo rm -r /etc/apt/keyrings/nodesource.gpg

RPM系统

# 卸载Node.js
sudo yum remove nodejs &&\
sudo rm -r /etc/yum.repos.d/nodesource.repo

📝 项目结构说明

项目主要包含以下关键目录和文件:

  • scripts/deb/: Debian/Ubuntu系统的安装脚本,如setup_24.x
  • scripts/rpm/: RPM系统的安装脚本,如setup_lts.x
  • scripts/deb/script_generator/: 脚本生成工具,包含generator.sh
  • scripts/rpm/script_generator/: RPM脚本生成工具

❓ 常见问题

Q: 如何安装特定版本的Node.js?
A: 只需将安装脚本中的版本号替换为所需版本,如setup_20.x对应Node.js 20.x系列。

Q: 支持哪些CPU架构?
A: 目前支持amd64(64位)、armhf(ARM 32位)和arm64(ARM 64位)架构。

Q: 如何获取企业级支持?
A: 对于非支持的Linux版本或需要专业支持,可以联系NodeSource获取企业级服务。

📚 相关文档

🔄 如何获取项目

要获取完整的项目代码,可以通过以下命令克隆仓库:

git clone https://gitcode.com/gh_mirrors/di/distributions

NodeSource Node.js Binary Distributions项目为开发者提供了简单、可靠的Node.js安装方案,无论是开发还是生产环境都能满足需求。通过本文介绍的方法,您可以在几分钟内完成Node.js的安装和配置,开始您的JavaScript开发之旅!

【免费下载链接】distributions NodeSource Node.js Binary Distributions 【免费下载链接】distributions 项目地址: https://gitcode.com/gh_mirrors/di/distributions

更多推荐