Installing Node.js via package manager

Note: 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.



Android

Android support is still experimental in Node.js, so precompiled binaries are not yet provided by Node.js developers.

However, there are some third-party solutions. For example, Termux community provides terminal emulator and Linux environment for Android, as well as own package manager and extensive collection of many precompiled applications. This command in Termux app will install the last available Node.js version:

pkg install nodejs

Currently, Termux Node.js binaries are linked against system-icu (depending on libicu package).

Arch Linux

Node.js and npm packages are available in the Community Repository.

pacman -S nodejs npm

CentOS, Fedora and Red Hat Enterprise Linux

Node.js is available as a module called nodejs in CentOS/RHEL 8 and Fedora.

dnf module install nodejs:<stream>

where <stream> corresponds to the major version of Node.js. To see a list of available streams:

dnf module list nodejs

For example, to install Node.js 12:

dnf module install nodejs:12

For CentOS/RHEL 7 Node.js is available via Software Collections.

Alternatives

These resources provide packages compatible with CentOS, Fedora, and RHEL.

Debian and Ubuntu based Linux distributions

Node.js binary distributions are available from NodeSource.

Alternatives

Packages compatible with Debian and Ubuntu based Linux distributions are available via Node.js snaps.

FreeBSD

The most recent release of Node.js is available via the www/node port.

Install a binary package via pkg:

pkg install node

Or compile it on your own using ports:

cd /usr/ports/www/node && make install

Gentoo

Node.js is available in the portage tree.

emerge nodejs

IBM i

LTS versions of Node.js are available from IBM, and are available via the 'yum' package manager. The package name is nodejs followed by the major version number (for instance, nodejs12, nodejs14 etc)

To install Node.js 14.x from the command line, run the following as a user with *ALLOBJ special authority:

yum install nodejs14

Node.js can also be installed with the IBM i Access Client Solutions product. See this support document for more details

macOS

Download the macOS Installer directly from the nodejs.org web site.

If you want to download the package with bash:

curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"

Alternatives

Using Homebrew:

brew install node

Using MacPorts:

port install nodejs<major version>

# Example
port install nodejs7

Using pkgsrc:

Install the binary package:

pkgin -y install nodejs

Or build manually from pkgsrc:

cd pkgsrc/lang/nodejs && bmake install

NetBSD

Node.js is available in the pkgsrc tree:

cd /usr/pkgsrc/lang/nodejs && make install

Or install a binary package (if available for your platform) using pkgin:

pkgin -y install nodejs

Nodenv

nodenv is a lightweight node version manager, similar to nvm. It's simple and predictable. A rich plugin ecosystem lets you tailor it to suit your needs. Use nodenv to pick a Node version for your application and guarantee that your development environment matches production.

Nodenv installation instructions are maintained on its Github page. Please visit that page to ensure you're following the latest version of the installation steps.

nvm

Node Version Manager is a bash script used to manage multiple released Node.js versions. It allows you to perform operations like install, uninstall, switch version, etc. To install nvm, use this install script.

On Unix / OS X systems Node.js built from source can be installed using nvm by installing into the location that nvm expects:

env VERSION=`python tools/getnodeversion.py` make install DESTDIR=`nvm_version_path v$VERSION` PREFIX=""

After this you can use nvm to switch between released versions and versions built from source. For example, if the version of Node.js is v8.0.0-pre:

nvm use 8

Once the official release is out you will want to uninstall the version built from source:

nvm uninstall 8

OpenBSD

Node.js is available through the ports system.

/usr/ports/lang/node

Using pkg_add on OpenBSD:

pkg_add node

openSUSE and SLE

Node.js is available in the main repositories under the following packages:

For example, to install Node.js 4.x on openSUSE Leap 42.2, run the following as root:

zypper install nodejs4

SmartOS and illumos

SmartOS images come with pkgsrc pre-installed. On other illumos distributions, first install pkgsrc, then you may install the binary package as normal:

pkgin -y install nodejs

Or build manually from pkgsrc:

cd pkgsrc/lang/nodejs && bmake install

Snap

Node.js snaps are available as node on the Snap store.

Solus

Solus provides Node.js in its main repository.

sudo eopkg install nodejs

Void Linux

Void Linux ships Node.js stable in the main repository.

xbps-install -Sy nodejs

Windows

Download the Windows Installer directly from the nodejs.org web site.

Alternatives

Using Chocolatey:

cinst nodejs
# or for full install with npm
cinst nodejs.install

Using Scoop:

scoop install nodejs
Scroll to top
热爱前端开发,专注分享前端最新技术、大厂面试题、聊点程序员轶事、职场感悟,做前端技术的传播者.

加入前端进阶交流群

扫描二维码回复 加群 学习,与大厂大佬讨论技术.