安装
通过 npm 安装
¥Install via npm
建议通过 npm 包管理器 安装 Yarn,当你在系统上安装 Yarn 时,它会与 Node.js 打包在一起。
¥It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system.
安装 npm 后,你可以运行以下命令来安装和升级 Yarn:
¥Once you have npm installed you can run the following both to install and upgrade Yarn:
npm install --global yarn
备择方案
单击展开/折叠
Alpine
在 Alpine Linux (3.6+) 上,你可以使用 apk 安装 Yarn。
apk add yarn
```</div>
<div class="install-only-rc install-only-nightly" markdown="1">目前,没有可用于 RC 或日常构建 Yarn 的 Alpine 软件包。请使用压缩包:<a id="installation-script"></a>
#### 安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments
is via our shell script. You can install Yarn by running the following code in
your terminal:
<div class="install-only-stable" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
Arch Linux
On Arch Linux, Yarn can be installed through the official package manager.
pacman -S yarn
目前,没有可用于 RC 或日常构建 Yarn 的 Arch 软件包。请使用压缩包:
安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
CentOS / Fedora / RHEL
On CentOS, Fedora and RHEL, you can install Yarn via our RPM package repository.
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
如果你尚未安装 Node.js,你还应该配置 NodeSource 存储库:
¥If you do not already have Node.js installed, you should also configure the NodeSource repository:
curl --silent --location https://rpm.nodesource.com/setup_12.x | sudo bash -
然后你可以简单地:
¥Then you can simply:
sudo yum install yarn
## OR ##
sudo dnf install yarn
目前,没有可用于 RC 或日常构建 Yarn 的 RPM 包。请使用压缩包:
安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
Debian / Ubuntu
在 Debian 或 Ubuntu Linux 上,你可以通过我们的 Debian 软件包存储库安装 Yarn。你首先需要配置存储库:
¥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
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ rc main" | sudo tee /etc/apt/sources.list.d/yarn.list
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://nightly.yarnpkg.com/debian/ nightly main" | sudo tee /etc/apt/sources.list.d/yarn.list
```</div>
在 Ubuntu 16.04 或更低版本以及 Debian Stable 上,你还需要配置 [NodeSource 存储库](https://github.com/nodesource/distributions/blob/master/README.md#deb) 以获得足够新的 Node.js 版本。
¥On Ubuntu 16.04 or below and Debian Stable, you will also need to configure [the NodeSource repository](https://github.com/nodesource/distributions/blob/master/README.md#deb) to get a new enough version of Node.js.
然后你可以简单地:
¥Then you can simply:
```sh
sudo apt update && sudo apt install yarn
注意:Ubuntu 17.04 默认安装了 cmdtest
。如果你在安装 yarn
时遇到错误,你可能需要先运行 sudo apt remove cmdtest
。请参阅 this 了解更多信息。
¥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.
如果使用 nvm
,你可以通过执行以下操作来避免安装 node
:
¥If using nvm
you can avoid the node
installation by doing:
sudo apt update && sudo apt install --no-install-recommends yarn
注意:由于在某些发行版中使用 nodejs
而不是 node
名称,yarn
可能会抗诉未安装 node
。解决此问题的方法是在 .bashrc
文件中添加别名,如下所示:alias node=nodejs
。这会将 yarn
指向你决定使用的 node
的任何版本。
¥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,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
Gentoo Linux
在 Gentoo Linux 上,你可以使用 portage 安装 Yarn。
sudo emerge --ask sys-apps/yarn
```</div>
<div class="install-only-rc install-only-nightly" markdown="1">目前,没有可用于 RC 或日常构建 Yarn 的 Gentoo 软件包。请使用压缩包:<a id="installation-script"></a>
#### 安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments
is via our shell script. You can install Yarn by running the following code in
your terminal:
<div class="install-only-stable" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
macOS
Homebrew
你可以通过 Homebrew 包管理器 安装 Yarn。如果尚未安装 Node.js,这也会安装它。
¥You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed.
brew install yarn
如果你使用 nvm 或类似版本,则应确保 PATH
在 Homebrew 安装的 Node.js 版本之前列出 nvm 的 shim。
¥If you use nvm or similar, you should ensure that your PATH
lists nvm’s shims before the version of Node.js installed by Homebrew.
MacPorts
你可以通过 MacPorts 安装 Yarn。如果尚未安装 Node.js,这也会安装它。
¥You can install Yarn through MacPorts. This will also install Node.js if it is not already installed.
sudo port install yarn
安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
目前,没有可用于 RC 或日常构建 Yarn 的 Homebrew 或 MacPorts 软件包。请使用压缩包:
安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
升级 Yarn
¥Upgrade Yarn
如果有新版本可用,Yarn 会警告你。要升级 Yarn,你可以使用 Homebrew 来完成。
¥Yarn will warn you if a new version is available. To upgrade Yarn, you can do so with Homebrew.
brew upgrade yarn
Solus
在 Solus 上,你可以通过 Solus 存储库安装 Yarn。
sudo eopkg install yarn
```</div>
<div class="install-only-rc install-only-nightly" markdown="1">目前,没有可用于 RC 或日常构建 Yarn 的 Solus 软件包。请使用压缩包:<a id="installation-script"></a>
#### 安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments
is via our shell script. You can install Yarn by running the following code in
your terminal:
<div class="install-only-stable" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
Windows
在 Windows 上安装 Yarn 可以使用三个选项。</div>
下载安装程序
¥Download the installer
这将为你提供一个 .msi
文件,运行该文件时将引导你在 Windows 上安装 Yarn。
¥This will give you a .msi
file that when run will walk you through installing
Yarn on Windows.
如果你使用安装程序,你首先需要安装 Node.js。
¥If you use the installer you will first need to install Node.js.
¥Download Installer Download Installer (RC) Download Installer (Nightly)
Install via Chocolatey
Chocolatey 是 Windows 的包管理器。你可以按照 这些说明 安装 Chocolatey。
¥Chocolatey is a package manager for Windows. You can install Chocolatey by following these instructions.
安装 Chocolatey 后,你可以通过在控制台中运行以下代码来安装 Yarn:
¥Once you have Chocolatey installed, you may install yarn by running the following code in your console:
choco install yarn
这也将确保你已安装 Node.js。
¥This will also ensure that you have Node.js installed.
通过 Scoop 安装
¥Install via Scoop
Scoop 是 Windows 的命令行安装程序。你可以按照 这些说明 安装 Scoop。
¥Scoop is a command-line installer for Windows. You can install Scoop by following these instructions.
安装了 Scoop 后,你可以通过在控制台中运行以下代码来安装 Yarn:
¥Once you have Scoop installed, you may install yarn by running the following code in your console:
scoop install yarn
如果 Node.js 没有安装,scoop 会给你安装的建议。示例:
¥If Node.js is not installed, scoop will give you a suggestion to install it. Example:
scoop install nodejs
注意
¥Notice
请在防病毒软件中将你的项目文件夹和 Yarn 缓存目录 (%LocalAppData%\Yarn) 列入白名单,否则安装包的速度会明显变慢,因为每个文件在写入磁盘时都会被扫描。
¥Please whitelist your project folder and the Yarn cache directory (%LocalAppData%\Yarn) in your antivirus software, otherwise installing packages will be significantly slower as every single file will be scanned as it’s written to disk.
备择方案
如果你使用的是其他操作系统,或者特定于你的操作系统的其他选项之一不适合你,则有多种选择。如果你尚未安装,则需要 安装 Node.js。
¥If you are using another OS or one of the other options specific to your OS will not work for you, there are a couple of alternatives. You will need to install Node.js if you don’t already have it installed.
在 Debian、Ubuntu 和 CentOS 等常见 Linux 发行版上,建议通过我们的软件包安装 Yarn。
¥On common Linux distributions such as Debian, Ubuntu and CentOS, it is recommended to install Yarn via our packages instead.
安装脚本
¥Installation Script
在 macOS 和通用 Unix 环境上安装 Yarn 最简单的方法之一是通过我们的 shell 脚本。你可以通过在终端中运行以下代码来安装 Yarn:
¥One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:
curl -o- -L https://yarn.nodejs.cn/install.sh | bash
```</div>
<div class="install-only-rc" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --rc
```</div>
<div class="install-only-nightly" markdown="1">```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --nightly
```</div>
安装过程包括验证 GPG 签名。[查看 GitHub 上的源代码](https://github.com/yarnpkg/website/blob/master/install.sh)
¥The installation process includes verifying a GPG signature.
[View the source on GitHub](https://github.com/yarnpkg/website/blob/master/install.sh)
<div class="install-only-stable" markdown="1">
You can also specify a version by running the following code in your terminal:
```sh
curl -o- -L https://yarn.nodejs.cn/install.sh | bash -s -- --version [version]
请参阅 发布 了解可能的版本。
¥See the releases for possible versions.
通过 tarball 手动安装
¥Manual Install via tarball
你可以通过 下载 tarball 安装 Yarn 并将其解压到任何地方。
¥You can install Yarn by downloading a tarball and extracting it anywhere.
cd /opt
wget https://yarn.nodejs.cn/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-rc" markdown="1">```sh
cd /opt
wget https://yarn.nodejs.cn/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
<div class="install-only-nightly" markdown="1">```sh
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
```</div>
在提取 Yarn 之前,建议你使用 GPG 验证 tarball:
¥Before extracting Yarn, it is recommended that you verify the tarball using GPG:
```sh
wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarn.nodejs.cn/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output
路径设置
¥Path Setup
Unix/Linux/macOS
如果在你的 PATH 中找不到 Yarn,请按照以下步骤添加它并允许它从任何地方运行。
¥If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.
注意:你的个人资料可能位于 .profile
、.bash_profile
、.bashrc
、.zshrc
等中。
¥Note: your profile may be in your .profile
, .bash_profile
, .bashrc
, .zshrc
, etc.
-
将其添加到你的个人资料中:
export PATH="$PATH:/opt/yarn-[version]/bin"
(路径可能会根据你提取 Yarn 的位置而有所不同)¥Add this to your profile:
export PATH="$PATH:/opt/yarn-[version]/bin"
(the path may vary depending on where you extracted Yarn to) -
在终端中,登录并注销以使更改生效
¥In the terminal, log in and log out for the changes to take effect
要全局访问 Yarn 的可执行文件,你需要在终端中设置 PATH
环境变量。为此,请将 export PATH="$PATH:
yarn global bin"
添加到你的个人资料中,或者如果你使用 Fish shell,只需运行命令 set -U fish_user_paths (yarn global bin) $fish_user_paths
¥To have access to Yarn’s executables globally, you will need to set up the PATH
environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`"
to your profile, or if you use Fish shell, simply run the command set -U fish_user_paths (yarn global bin) $fish_user_paths
Windows
你需要在终端中设置 PATH
环境变量才能全局访问 Yarn 的二进制文件。
¥You will need to set up the PATH
environment variable in your terminal to have access to Yarn’s binaries globally.
将 set PATH=%PATH%;C:\.yarn\bin
添加到你的 shell 环境中。
¥Add set PATH=%PATH%;C:\.yarn\bin
to your shell environment.
检查安装
通过运行以下命令检查 Yarn 是否已安装:
yarn --version