Installing Node.js via package manager

本文详细介绍了如何在不同操作系统(如Debian、Ubuntu、Fedora、RHEL、Arch Linux等)上安装并配置Node.js与npm,包括使用包管理器、手动编译和依赖管理等内容,旨在帮助开发者快速部署Node.js应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The packages on this page are maintained and supported by their respective packagers, not the node.js core team. Please report any issues you encounter to the package maintainer. If it turns out your issue is a bug in node.js itself, the maintainer will report the issue upstream.

Gentoo

Node.js is available in the portage tree.

# emerge nodejs

Debian, LMDE

Node.js is available in official repo for Debian Sid(unstable).

For Debian Wheezy, you have two options:

Build from source

sudo apt-get install python g++ make checkinstall fakeroot
src=$(mktemp -d) && cd $src
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
./configure
fakeroot checkinstall -y --install=no --pkgversion $(echo $(pwd) | sed -n -re's/.+node-v(.+)$/\1/p') make -j$(($(nproc)+1)) install
sudo dpkg -i node_*
Uninstall
sudo dpkg -r node

Backports

Alternatively, you can install nodejs from wheezy-backports. If you rely on having node as an executable, install nodejs-legacy as well.

If you need npm as well, you can get it through the installer

curl https://www.npmjs.org/install.sh | sudo sh

Ubuntu, Mint, elementary OS

From Ubuntu 12.04 to 13.04, an old version (0.6.x) of Node is in the standard repository. To install, just run:

sudo apt-get install nodejs

Obtaining a recent version of Node or installing on older Ubuntu and other apt-based distributions may require a few extra steps. Example install:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

It installs current stable Node on the current stable Ubuntu. 12.10 and 13.04 users may need to install the software-properties-commonpackage for the add-apt-repository command to work: sudo apt-get install software-properties-common.

The command add-apt-repository is actually provided by the python-software-properties package. So you will have to install this one as wellsudo apt-get install python-software-properties.

As of Node.js v0.10.0, the nodejs package from Chris Lea's repo includes both npm and nodejs-dev.

There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed fromnode to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

openSUSE & SLE

Node.js stable repos list. Also node.js is available in openSUSE:Factory repository.

Available RPM packages for: openSUSE 11.4, 12.1, Factory and Tumbleweed; SLE 11 (with SP1 and SP2 variations).

Example install on openSUSE 12.1:

sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_12.1/ NodeJSBuildService 
sudo zypper in nodejs nodejs-devel

Fedora

Node.js and npm are available in Fedora 18 and later. Just use your favorite graphical package manager or run this on a terminal to install both npm and node:

sudo yum install nodejs npm

RHEL/CentOS/Scientific Linux 6

Node.js and npm are available from the Fedora Extra Packages for Enterprise Linux (EPEL) repository. If you haven't already done so, firstenable EPEL.

To check if you have EPEL, run

yum repolist

if you don't see epel, install it via RPM (At the time of this writing, the last version is 6.8.).

First import the key:

sudo rpm --import https://fedoraproject.org/static/0608B895.txt

Then install

sudo rpm -Uvh http://download-i2.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

And then run the following command to install node and npm:

sudo yum install nodejs npm --enablerepo=epel

or if this doesn't work for you install node separately:

sudo yum install npm --enablerepo=epel

Arch Linux

Node.js is available in the Community Repository.

pacman -S nodejs

FreeBSD and OpenBSD

Node.js is available through the ports system.

/usr/ports/www/node

Development versions are also available using ports

cd /usr/ports/www/node-devel/ && make install clean

or packages on FreeBSD

pkg_add -r node-devel

Using pkg-ng on FreeBSD

pkg install node

or the development versions

pkg install node-devel

OSX

Using a package

Simply download Macintosh Installer.

Using Fink:

fink install nodejs

Using homebrew:

brew install node

Using macports:

port install nodejs  

Windows

Using a package

Simply download Windows Installer.

Using chocolatey to install Node:

cinst nodejs  

or for full install with NPM:

cinst nodejs.install

Using Scoop to install Node:

scoop install nodejs

 

from:https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值