admin 发布的文章

NodeSource Node.js Binary Distributions

NodeSource

CircleCI

This repository contains documentation for using the NodeSource Node.js Binary Distributions via .rpm, .deb and Snap packages as well as their setup and support scripts.

If you are looking for NodeSource's low-impact Node.js performance monitoring platform, please get started here.

Please file an issue if you are experiencing a problem or would like to discuss something related to the distributions.

Pull requests are encouraged if you have changes you believe would improve the setup process or increase compatibility across Linux distributions.

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)
  • Ubuntu 19.10 (Eoan Ermine)
  • Ubuntu 20.04 LTS (Focal Fossa)

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 / oldoldstable (Jessie)
  • Debian 9 / oldstable (Stretch)
  • Debian 10 / stable (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)
  • Linux Mint 19.1 "Tessa" (via Ubuntu 18.04 LTS)
  • Linux Mint 19.2 "Tina" (via Ubuntu 18.04 LTS)
  • Linux Mint 19.3 "Tricia" (via Ubuntu 18.04 LTS)
  • Linux Mint Debian Edition (LMDE) 3 "Cindy" (via Debian 9)
  • Linux Mint Debian Edition (LMDE) 4 "Debbie" (via Debian 10)

Supported Devuan versions:

  • Jessie / oldstable (via Debian 8)
  • Ascii / stable (via Debian 9)
  • Beowulf / testing (via Debian 10)
  • Ceres / unstable (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)
  • elementary OS Hera (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)
  • BOSS 7.0 "Drishti" (via Debian 9)
  • BOSS 8.0 "Unnati" (via Debian 10)

Supported BunsenLabs versions:

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

Supported MX Linux versions:

  • MX-17 Horizon (via Debian 9)
  • MX-18 Continuum (via Debian 9)
  • MX-19 Patito Feo (via Debian 10)

Supported Sparky Linux versions:

  • Sparky 4.x "Tyche" (via Debian 9)
  • Sparky 5.x "Nibiru" (via Debian 10)

Supported PureOS Linux versions:

  • PureOS 9.0 "Amber" (via Debian 10)

Supported Astra Linux CE versions:

  • Astra Linux CE 2.12 "Orel" (via Debian 9)

Installation instructions

Node.js v14.x:

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

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

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 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

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.x and later
  • x86_64 (64-bit)

Supported Red Hat® Enterprise Linux® versions:

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

Supported CentOS versions:

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

Supported CloudLinux versions:

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

Supported Fedora versions:

  • Fedora 30 (64-bit) - available for Node.js 10.16.0 and later
  • Fedora 31 (64-bit) - available for Node.js 10.17.0 and later
  • Fedora 32 (64-bit)

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 14.x

# As root
curl -sL https://rpm.nodesource.com/setup_14.x | bash -

# No root privileges 
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -

NodeJS 12.x

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

# No root privileges 
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -

NodeJS 10.x

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

# No root privileges 
curl -sL https://rpm.nodesource.com/setup_10.x | sudo 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'

Snap packages

About

Snaps are containerized software packages designed to work across cloud, desktop, and IoT devices. They work natively on most popular Linux distributions and feature automatic transactional updates.

The NodeSource-managed Node.js snap contains the Node.js runtime, along with the two most widely-used package managers, npm and Yarn. They are delivered from the snapcraft store and are automatically built and pushed for each supported Node.js release line. Generally you will have a new version of Node.js automatically running on your computer the same day it is released on nodejs.org.

The Node.js snap can currently be installed on Arch Linux, Debian, Fedora, Linux Mint, Manjaro, OpenEmbedded/Yocto, OpernWrt, Solus, Ubuntu and many other distributions built on top these. NodeSource has not tested the Node.js snap on all of these distributions and feedback is welcome in this repository if you run into problems.

Installation instructions

The snap command ships with Ubuntu, from version 16.04 and later. If you do not have it installed, follow the instructions on snapcraft to install snapd.

Snaps are delivered via "channels"; for Node.js, the channel names are the major-version number of Node.js. So select a supported Node.js version and install with:

sudo snap install node --classic --channel=8

Substituting 8 for the major version you want to install. Both LTS and Current versions of Node.js are available via snapcraft.

The --classic argument is required here as Node.js needs full access to your system in order to be useful, therefore it needs snap’s "classic confinement". By default, snaps are much more restricted in their ability to access your disk and network and must request special access from you where they need it. Note that on some Linux distributions, the snap confinement mechanisms are not fully supported so --classic may not be necessary or even supported.

Once installed, the node, npm and yarn commands are available for use and will remain updated for the channel you selected.

Switching channels

You can use the refresh command to switch to a new channel at any time:

sudo snap refresh node --channel=10

Once switched, snapd will update Node.js for the new channel you have selected.

Bleeding-edge Node.js

Users feeling adventurous or interested in testing the latest code from the Node.js core developers can install from the "edge" channel. This has an element of risk: it is a direct pipeline from the upstream Node.js git repository to the snap store every day and previews the ongoing development work and may include breaking changes slated for the next major version of Node.js. This is only recommend for those users who are willing to participate in testing and bug reporting upstream:

sudo snap install node --classic --channel=edge

Not recommended for production deployments

Due to their auto-updating nature, snaps are not necessarily appropriate for the deployment of your Node.js applications to production. NodeSource recommends a stable and integration-tested deployment pipeline for production applications such as the .deb or .rpm distributions outlined above. However, snaps are an excellent way to keep developer machines updated and allow for trivial and convenient switching between Node.js versions.

Advanced usage

The snap man page, or Canonical’s advanced snap usage tutorial contains details of advanced snapd functionality.

Tests

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

curl -sL https://deb.nodesource.com/test | bash -

FAQ

Q: How do I use this repo when behind a proxy?

A: Please take a look at issue #9


Q: How do I pin to specific versions of Node.js?

A: Please take a look at issue #33


Q: I upgraded to a new major version of Node.js using the scripts, but the old version is still being installed, what is going on?

A: You probably need to clear out your package manager's cache. Take a look at issue #191


Q: I'm trying to install Node.js on CentOS 5 / RHEL 5 and it is failing, why?

A: Due to the limitations of the compiler toolchain on EL 5 and its end of general support, we no longer support. See issue #190


Q: I'm seeing "Your distribution, identified as ".i686" or ".i386, is not currently supported, why?

A: Node.js 4.x and newer require a 64bit os for rpms. See issue #268


Q: Why have certain versions of platforms/releases stopped receiving updates to Node.js?

A: Unfortunately, newer versions of V8 require a modern compiler toolchain. On some platforms, such as ARM wheezy, that toolchain is not available. See issue #247


Q: Why is my Node.js version newer than the one of the script I’ve run?

A: Your package manager is probably installing a newer Node.js version from a different source. See issue #657


Q: What is the current status of IPv6 support?

A: See issue #170

Requested Distributions

We, unfortunately, do not have the resources necessary to support and test the plethora of Linux releases in the wild, so we rely on community members such as yourself to get support on your favorite distributions! This is a list of releases that have been requested by the community. If you are interested in contributing to this project, this would be a great place to start!

Authors and Contributors

Chris LeaGitHub/chrisleaTwitter/@chrislea
Rod VaggGitHub/rvaggTwitter/@rvagg
William BlankenshipGitHub/retrohackerTwitter/@retrohack3r
Harry TruongGitHub/harrytruong
Matteo BrunatiGitHub/mattbrun
Brian WhiteGitHub/mscdex
Matt LewandowskyGitHub/lewellyn
Jan-Hendrik PetersGitHub/hennr
Andris ReinmanGitHub/andris9
CarvilsiGitHub/carvilsi
Krasimir TrenchevGitHub/Ava7
Phil HelmGitHub/phelma
0xmohitGitHub/0xmohit
jdarlingGitHub/jdarling
Prayag VermaGitHub/pra85
Misha BrukmanGitHub/mbrukman
Simon LydellGitHub/lydell
Sebastian BleiGitHub/iamsebastian
Jorge Maldonado VenturaNotABug/jorgesumle
Mayank MethaGitHub/mayankmethaTwitter/@mayankmethad
Adrian EstradaGitHub/edsadrTwitter/@edsadr
Iván IguaránGitHub/igsu

Contributions are welcomed from anyone wanting to improve this project!

License

This material is Copyright (c) NodeSource and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.


Supported with love by Chris Lea, Rod Vagg and the NodeSource team

This project is not affiliated with Debian, Ubuntu, Red Hat, CentOS or Fedora.

Ubuntu is a registered trademark of Canonical Ltd.

Debian is a registered trademark owned by Software in the Public Interest, Inc.

Red Hat, CentOS and Fedora are trademarks of Red Hat, Inc.

CloudLinux is a trademark of Cloud Linux, Inc

npn install -g yrm --registry https://registry.npm.taobao.org

https://yarn.bootcss.com/docs/install/#debian-stable

Debian / Ubuntu

On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the repository:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

On Ubuntu 16.04 or below and Debian Stable, you will also need to configure the NodeSource repository to get a new enough version of Node.js.

Then you can simply:

sudo apt update && sudo apt install yarn

Note: Ubuntu 17.04 comes with cmdtest installed by default. If you’re getting errors from installing yarn, you may want to run sudo apt remove cmdtest first. Refer to this for more information.

If using nvm you can avoid the node installation by doing:

sudo apt update && sudo apt install --no-install-recommends yarn

Note: Due to the use of nodejs instead of node name in some distros, yarn might complain about node not being installed. A workaround for this is to add an alias in your .bashrc file, like so: alias node=nodejs. This will point yarn to whatever version of node you decide to use.
Path Setup

如果未在 PATH 环境变量中找到 yarn,请按照以下步骤添加 yarn 到 PATH 环境变量中,使其可以随处运行。

注意:您的配置文件可能是 .profile、.bash_profile、.bashrc、.zshrc 等。

将此项加入您的配置文件: export PATH="$PATH:/opt/yarn-[version]/bin" (路径可能根据您安装 Yarn 的位置而有差异)
在终端中,执行登录并登出以使更改生效

为了可以全局访问 Yarn 的可执行文件,你需要在控制台(或命令行)中设置 PATH 环境变量。若要执行此操作,请添加 export PATH="$PATH:yarn global bin" 到你的配置文件中,或者,如果你使用的是 Fish shell,直接执行此命令 set -U fish_user_paths (yarn global bin) $fish_user_paths 即可。

通过如下命令测试 Yarn 是否安装成功:

yarn --version

https://blog.csdn.net/aliaichidantong/article/details/102637413

一、编辑网卡文件

vi /etc/network/interfaces

二、修改网卡文件

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
     
    # The loopback network interface
     
    auto lo
    iface lo inet loopback
     
    # The primary network interface
     
    auto eth0
    # iface eth0 inet6 dhcp
    iface eth0 inet6 static
    address 2001:da8:203:ec8:a00:27ff:fe6b:7ed
    netmask 64
    gateway 2001:da8::1
    iface eth0 inet static
    address 192.168.1.193
    netmask 255.255.255.0
    gateway 192.168.1.1

三、添加IPV6路由

    route -A inet6 add default gw 2001:da8:203:ec8::1 dev eth0
   
    #接口启用时添加一条路由
    # up route -A inet6 add default gw 2001:da8:203:ec8::1 dev eth0
    #接口不可用时删除一条路由
    #down route -A inet6 add default gw 2001:da8:203:ec8::1 dev eth0
    #添加静态路由包含下一跳
    #格式为  route -A inet6 add  网关/掩码前缀   gw  ip地址  dev 网卡
    route -A inet6 add 2002:db8:1::/64 gw 2001:da8:203:ec8:f74e:76ea:3ee:7704 dev eth0
    #想要访通不同网段的地址,就需要添加路由,用对方同网段的IP地址当作网关路由,再通过网关(需要跨网段的那个网关)来访问地址
    #比如说我的地址现在是2001:da8:203:ec8:f74e:76ea:3ee:7705 ,想要访问2002:db8:1::1 地址,就需要
    #通过同网段的2001:da8:203:ec8:f74e:76ea:3ee:7704目标服务器来访问2002:db8:1::1的网关来访问目的
    #地址(第一次接触,说的不够通俗易懂,有易懂的描述,希望大家提出来)

四、查看IPV6静态路由

route -6

五、扩展

192.168.1.193/24 和 2001:da8:203:ec8:a00:27ff:fe6b:7ec/64 后面数字含义

个人理解代表掩码,也可以计算子网的ip个数

24说明网络位是24位,那么主机位就是32-24=8位了,则子网的IP个数是254个,即是从00000001到11111110.

28位说明网络位是28位,那么主机位4位,则子网的IP个数是14个,即是从00000001到00001110.

IPV6同理

https://www.cnblogs.com/qiuxiangmuyu/p/6343841.html 一些对inteface文件配置的详细解释

六、route参数解释

Destination     目标网段或者主机
Gateway     网关地址,”*” 表示目标是本主机所属的网络,不需要路由
Genmask     网络掩码
Flags     标记。一些可能的标记如下:
      U — 路由是活动的
      H — 目标是一个主机
      G — 路由指向网关
      R — 恢复动态路由产生的表项
      D — 由路由的后台程序动态地安装
      M — 由路由的后台程序修改
      ! — 拒绝路由
Metric     路由距离,到达指定网络所需的中转数(linux 内核中没有使用)
Ref     路由项引用次数(linux 内核中没有使用)
Use     此路由项被路由软件查找的次数
Iface     该路由表项对应的输出接口

参考:https://www.cnblogs.com/baiduboy/p/7278715.html

七、IPV6测试网络通信

IPV6的ping和IPV4不一样,需要使用ping6

ping6 2001:da8:203:ec8:f74e:76ea:3ee:7704