欢迎观临
路漫漫其修远兮,吾将上下而求索

linux下通过NodeSource安装最新的nodejs

Table of Contents

Debian and Ubuntu based distributions

Available architectures:

NodeSource will continue to maintain the following architectures and may add additional ones in the future.

  • i386 (32-bit)—not available for Node.js 10 and later
  • amd64 (64-bit)
  • armhf (ARM 32-bit hard-float, ARMv7 and up: arm-linux-gnueabihf)
  • arm64 (ARM 64-bit, ARMv8 and up: aarch64-linux-gnu)

Supported Ubuntu versions:

NodeSource will maintain Ubuntu distributions in active support by Canonical, including LTS and the intermediate releases.

  • Ubuntu 14.04 LTS (Trusty Tahr) – not available for Node.js 10 and later
  • Ubuntu 16.04 LTS (Xenial Xerus)
  • Ubuntu 18.04 LTS (Bionic Beaver)
  • Ubuntu 18.10 (Cosmic Cuttlefish)
  • Ubuntu 19.04 (Disco Dingo)

Supported Debian versions:

NodeSource will maintain support for stable, testing and unstable releases of Debian, due to the long release cycle a considerable number of users are running unstable.

  • Debian 8 / oldstable (Jessie)
  • Debian 9 / stable (Stretch)
  • Debian 10 / testing (Buster)
  • Debian unstable (Sid)

Supported Linux Mint versions:

  • Linux Mint 17 "Qiana" (via Ubuntu 14.04 LTS) – not available for Node.js 10 and later
  • Linux Mint 17.1 "Rebecca" (via Ubuntu 14.04 LTS) – not available for Node.js 10 and later
  • Linux Mint 17.2 "Rafaela" (via Ubuntu 14.04 LTS) – not available for Node.js 10 and later
  • Linux Mint 18 "Sarah" (via Ubuntu 16.04 LTS)
  • Linux Mint 18.1 "Serena" (via Ubuntu 16.04 LTS)
  • Linux Mint 18.2 "Sonya" (via Ubuntu 16.04 LTS)
  • Linux Mint 18.3 "Sylvia" (via Ubuntu 16.04 LTS)
  • Linux Mint Debian Edition (LMDE) 2 "Betsy" (via Debian 8)
  • Linux Mint 19 "Tara" (via Ubuntu 18.04 LTS)

Supported Devuan versions:

  • Jessie (via Debian 8)
  • Ascii (via Debian 9)
  • Ceres (via Debian unstable)

Supported elementary OS versions:

  • elementary OS Freya (via Ubuntu 14.04 LTS) – not available for Node.js 10 and later
  • elementary OS Loki (via Ubuntu 16.04 LTS)
  • elementary OS Juno (via Ubuntu 18.04 LTS)

Supported Trisquel versions:

  • Trisquel 7 "Belenos" (via Ubuntu 14.04 LTS) – not available for Node.js 10 and later
  • Trisquel 8 "Flidas" (via Ubuntu 16.04 LTS)

Supported BOSS versions:

  • BOSS 5.0 "Anokha" (via Debian 7) – not available for Node.js 10 and later
  • BOSS 6.0 "Anoop" (via Debian 8)

Supported BunsenLabs versions:

  • Hydrogen (via Debian 8)
  • Helium (via Debian 9)

Installation instructions

Node.js v12.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

Node.js v11.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs

Node.js v10.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs

Node.js v8.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

# use `sudo` on Ubuntu or run this as root on debian
apt-get install -y build-essential

Manual installation

If you’re not a fan of curl <url> | bash -, or are using an unsupported distribution, you can try a manual installation.

These instructions assume sudo is present, however some distributions do not include this command by default, particularly those focused on a minimal environment. In this case, you should install sudo or su to root to run the commands directly.

1. Remove the old PPA if it exists

This step is only required if you previously used Chris Lea’s Node.js PPA.

# add-apt-repository may not be present on some Ubuntu releases:
# sudo apt-get install python-software-properties
sudo add-apt-repository -y -r ppa:chris-lea/node.js
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save

2. Add the NodeSource package signing key

curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
# wget can also be used:
# wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

3. Add the desired NodeSource repository

# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
VERSION=node_8.x
# The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
# - For Debian distributions: jessie, sid, etc...
# - For Ubuntu distributions: xenial, bionic, etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
DISTRO="$(lsb_release -s -c)"
echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

4. Update package lists and install Node.js

sudo apt-get update
sudo apt-get install nodejs

Enterprise Linux based distributions

Available architectures:

NodeSource will continue to maintain the following architectures and may add additional ones in the future.

  • i386 (32-bit)—not available for all distros and not available for Node.js 10 and later
  • x86_64 (64-bit)

Supported Red Hat® Enterprise Linux® versions:

  • RHEL 6 (64-bit)
  • RHEL 7 (64-bit)

Supported CentOS versions:

  • CentOS 6 (64-bit)
  • CentOS 7 (64-bit)

Supported CloudLinux versions:

  • CloudLinux 6 (32-bit for Node <= 10.x and 64-bit)

Supported Fedora versions:

  • Fedora 27 (32-bit for Node <= 10.x and 64-bit)
  • Fedora 28 (64-bit)
  • Fedora 29 (64-bit) for Node >= 10.13.0

Equivalent versions of Korora Linux should also be supported.

Installation instructions

_NOTE: If you are using RHEL 6 or CentOS 6, you might want to read about running Node.js on older distros._

Run as root on RHEL, CentOS, CloudLinux or Fedora:

NodeJS 12.x

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

NodeJS 11.x

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

NodeJS 10.x

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

NodeJS 8.x

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

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

yum install gcc-c++ make
# or: yum groupinstall 'Development Tools'

Tests

To test an installation is working (and that the setup scripts are working!) use:

curl -sL https://deb.nodesource.com/test | bash -
赞(3) 打赏
未经允许不得转载:云海鹰影博客 » linux下通过NodeSource安装最新的nodejs
分享到: 更多 (0)

欢迎留言 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏