Daocloud Docker 镜像站

Linux

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档。
macOS

Docker For Mac

右键点击桌面顶栏的 docker 图标,选择 Preferences ,在 Daemon 标签(Docker 17.03 之前版本为 Advanced 标签)下的 Registry mirrors 列表中加入下面的镜像地址:
http://f1361db2.m.daocloud.io

点击 Apply & Restart 按钮使设置生效。

Docker Toolbox 等配置方法请参考帮助文档。

Windows

Docker For Windows

在桌面右下角状态栏中右键 docker 图标,修改在 Docker Daemon 标签页中的 json ,把下面的地址:
http://f1361db2.m.daocloud.io

加到" registry-mirrors"的数组里。点击 Apply 。

Docker Toolbox 等配置方法请参考帮助文档。


SJTUG 上海交大软件源镜像服务

https://mirrors.sjtug.sjtu.edu.cn/#/

docker-registry 源是 Docker Hub 的反向代理,可以加速docker pull等需要下载镜像的命令。

使用方法:

编辑或新建/etc/docker/daemon.json文件,向其中添加registry-mirrors项,使最终配置类似:

{
  "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"],
  "registry-mirrors": ["https://registry.docker-cn.com", "https://docker.mirrors.sjtug.sjtu.edu.cn"]
}
systemctl daemon-reload
systemctl restart docker

原文地址:https://www.cnblogs.com/franknihao/p/8963634.html

【webssh】

  ——记两天来比较痛苦的历程

  广义上来说,webssh泛指一种技术可以在网页上实现一个SSH终端。从而无需Xshell之类的模拟终端工具进行SSH连接,将SSH这一比较低层的操作也从C/S架构扭成了B/S架构。

  能实现webssh的组件有好几种,但归根结底都是建立在客户端和服务端的即时通信上,有一些webssh只停留在这一层,表明客户端接入的ssh界面只是服务端本身的后台;另一种稍微高级一点的,将webssh做成一个通用的服务,网页上的ssh界面其实就和XShell一样,可以连接任何服务器可以连通的机器。由于一般服务器都会安装有ssh客户端软件,所以两者之间硬要说有很明显的区别其实也没有。

  下面来说一说我的需求吧,我做的一个资源管理系统中重要的一部分就是服务器。同时系统中也维护了各个服务器的用户和密码,那么如果在页面上按一个键,就能打开一个webssh,并且 自动登录 ,这样就能很方便地管理各个服务器了。

  基于这样一种需求的想法,我出发去找了一些项目,下面来说说几个找到的可能有用的:

■  GateOne

  项目地址: https://github.com/liftoff/GateOne

  详细的安装教程可以参考这篇:http://www.laozuo.org/10703.html

  这个东西被很多人称赞,使用了下也发现确实很牛。它是一个基于HTML5的webssh工程,不需要任何浏览器的任何插件就能无障碍运行。我感觉gateone最厉害的地方在于其强大的webssh界面。不仅仅是一块黑屏,它还支持多终端创建和切换,支持在终端中显示图片等内容,支持操作回放,日志审计等等功能。简直可以说比putty,XShell之类的桌面软件都要强大很多。但是その分,这个工程很大,需要的依赖很多。

  gateone的开发框架是tornado,刚好是python的,所以我看了它很长时间。。在保证有了tornado,paramiko等一系列依赖之后,下载来项目,可以考虑用python setup.py install来将gateone作为一个软件安装在服务器上,我采用的方法是python gateone.py这样的比较low的办法启动服务的。默认端口等等配置可以在gateone.py同目录下的server.conf中修改。哦对了,gateone默认使用了https协议,所以在访问的时候记得不要搞错了。

  部署完成之后,访问相关地址,可以看到gateone的界面。简单用了一下,界面的边上还有一连串工具栏,没有仔细研究,不过确实可以说是和桌面级软件一般的好用。

  不过gateone有个很大的缺点不符合我的需求,就是无法做到自动登录。gateone其实是作为一个通用的ssh客户端服务放在服务器上的,我无法在打开它的时候向其传递一些信息从而实现自动的ssh到某台服务器。为了自动登录,我甚至用jquery找到光标的DOM然后在它前面插入信息等方法,均告失败。粗粗看了下源码,觉得水平不足以改源码来实现。。于是放弃找其他办法

■  shellinabox

  这个项目也是一个很好的webssh,不过没有细看,因为它似乎只支持对于部署本地的访问,当然如果要访问出去也是可以,这样还是略显麻烦一点。而且自动登录的问题依然没有解决,我依然没有找到办法向webssh界面传递信息实现自动登录。

  在github上看似乎最新版本已经集合了很多其他插件比如IDE插件和其他一些美化界面的东西进去,看起来还是很漂亮的。

■  xterm.js

  晚上问了一下公司里有类似功能的项目是如何实现webssh的,结果被告知是使用了xterm.js,并且做这块的同事已经离职了。。只好自己研究了下xterm.js这个库。

  项目地址:https://github.com/xtermjs/xterm.js

  xterm.js是一个前端库,要实现一个完整的webssh还需要后端的支持。xterm的话可以认为它就是可以在前端画一个功能较为齐全的终端屏幕。

  哦对了,在跟着它的readme安装的时候还猜了不少坑,npm这个东西至今还是不太会用。前端的玩法有必要系统学一下。总之最后总算是搞出了xterm.js和xterm.css两个文件放到页面里实验了一下。确实画出了黑屏,不过没有交互啊。交互的话肯定要用websocket(其他双工交互方式肯定是效率不高的,简单用用可以,webssh传输强度比较大的东西还是算了),flask也就算了,django里的websocket基本不会。。无奈再回网上找找。

■  webssh

  项目地址: https://github.com/huashengdun/webssh

  最终找到了webssh(狭义)这个东西。其实同名的webssh之前我已经在github上找到一个,之前开运维技术大会时,听到别人的作品中也是用了那个组件。但是那里简介一看在一年前就已经不维护了,下来一试发现bug多得是,所以很快就放弃了。不过这次找到的webssh似乎和之前那个没啥关系,是同名的另一个项目。下来一试发现好得很,不仅能够实现基本的ssh界面,而且代码也不多,要自己改的话学习成本也不是很大。

  技术上,这个项目前端用的也是xterm.js,后端用的也是tornado,而且后端的目录结构相当简单易懂。部署上去之后访问进去一开始仍然是需要输入IP,端口,账号密码这些内容的界面。但是它明确写出了那个界面里用了哪些JS,于是我想到了可以在连接里加入GET参数,然后自建一个JS来把这些参数填入input中,然后再自动按一下submit,就可以实现自动登录了。

  这里不得不指出的是,webssh用的是http协议,安全方面上可能有一些不足。但是已经顾不得这么多了。。而且我把webssh部署在和我自己项目同一台服务器上,页面上采用了iframe访问webssh服务,所以相对好一点。 如果想要将webssh项目部署成https也简单,只要修改下webssh的tornado框架用到的一些源码就可以了。

  在main.py中,原先服务进程的监听启动是通过app.listen这样的方式来做的。现在只要将这部分注释掉然后重新建立一个http_server对象来监听:
复制代码

import tornado

...略

http_server = tornado.httpserver.HTTPServer(app, ssl_options={
'certfile': 'your/path/to/certificate.crt',
'keyfile': 'your/path/to/key.key'
})
http_server.listen(options.port,options.address)

...略

复制代码

  这样就可以通过https来访问webssh界面了。

  至此我的需求基本实现了,不过还有点不足,就是我不想把webssh默认的那个带有表单的界面展示出来,于是用了layer组件,在页面加载开始时就调出了一个加载界面并且指定shade为true,使得看不到后面的内容。请求成功后关掉layer,如果请求失败,就以layer.msg的方式将错误信息展现。按照webssh的main.js中默认的提示错误的方式,是将错误信息写在一个#status的div中,记得把status.text(xxx)之类的内容换成layer.msg即可。还有一个歪打正着的,默认情况输入exit退出ssh之后会回到表单界面,加上layer之后退出来不显示表单而是变成一块黑屏,很好。

  其余一些定制就是很简单了。比如把错误提示信息换成中文等等。

  这个过程中还遇到过两个小问题。第一个是当我的ssh区域作为一个iframe出现在页面上时,如果区域高度过小,比如小于400px时,ssh界面会锚定在最顶部。当输出比较多的命令被执行之后你就看不到光标了,除非盲打一个clear命令。。第二个是似乎webssh不支持很大量的数据交互。我尝试着cat了一个5M多的文件时,崩溃了。。不过我本来就是拿这个东西来做一个简单的ssh的,没必要继续加强性能。

  * 关于第一个问题还有一些小补充。webssh模拟终端的界面的大小是个很微妙的东西,上面说了高度的问题,另外还有一个宽度的问题。一般情况下,为了能够动态适配窗口的大小,我们可以实时获取window.height和window.width,然后通过计算获得到webssh终端合适的高和宽。对于width,webssh利用的前端组件xterm.js有一个问题就是最多每行只能显示80个字符。或许你可以尝试修改Terminal对象生成时传入方法的参数cols(其默认值是80),但是只要其值设置为大于80的时候就会发生超出80字符宽度部分的字符串不会自动换行,而是到本行开头去覆盖本行。

  google了挺久没有找到合适的解决方案,github上官方给出的解释是因为被连接服务器本身的tty终端字符宽度就是80,而xterm.js必须和这个宽度一样才可以正常工作。。为了webssh终端能够正常地自动换行同时也要尽量避免webssh终端区域大片屏幕都被浪费,一个曲线救国的办法就是把终端窗口宽度刚好调节成80个字符再宽一点点的样子,比如780px左右(根据屏幕大小不同可能不同)。

  以上。两天终于找到了一个好一点的解决办法。。

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