Yarn 安装

macOS

Homebrew

You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed.

brew install yarn

If you use nvm you should exclude installing Node.js so that nvm’s version of Node.js is used.

brew install yarn --ignore-dependencies
MacPorts

You can install Yarn through MacPorts. This will also install Node.js if it is not already installed.

sudo port install yarn
Path Setup

If you chose manual installation, the following steps will add Yarn to path variable and run it from anywhere.

Note: your profile may be in your .profile.bash_profile.bashrc.zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATHenvironment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile.

Test that Yarn is installed by running:

yarn --version

Windows

There are three options for installing Yarn on Windows.

Download the installer

This will give you a .msi file that when run will walk you through installing Yarn on Windows.

If you use the installer you will first need to install Node.js.

Download Installer

Install via Chocolatey

Chocolatey is a package manager for Windows, you can install Chocolatey by followingthese instructions.

Once you have Chocolatey installed, you may install yarn by running the following code in your console:

choco install yarn

This will also ensure that you have Node.js installed.

Install via Scoop

Scoop is a command-line installer for Windows, you can install Scoop by following these instructions.

Once you have Scoop installed, you may install yarn by running the following code in your console:

scoop install yarn

If Node.js is not installed, scoop will give you a suggestion to install it. Example:

scoop install nodejs
Notice

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.

Test that Yarn is installed by running:

yarn --version

Debian/Ubuntu Linux

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 14.04 and Debian Stable, you will also need to configure the NodeSource repository to get a new enough version of Node.js (Debian Testing and Ubuntu 16.04 come packaged with a sufficient version of Node.js, so this step is not required in those environments)

Then you can simply:

sudo apt-get update && sudo apt-get install yarn

CentOS / Fedora / RHEL

On CentOS, Fedora and RHEL, you can install Yarn via our RPM package repository.

sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo

If you do not already have Node.js installed, you should also configure the NodeSource repository:

curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

Then you can simply:

sudo yum install yarn

Arch Linux

On Arch Linux, Yarn can be installed through the official package manager.

pacman -S yarn

Solus

On Solus, you can install yarn via the Solus repository.

sudo eopkg install yarn

Alpine

On Alpine Linux (3.6+), you can install yarn with apk.

apk add yarn

Path Setup

If you chose manual installation, the following steps will add Yarn to path variable and run it from anywhere.

Note: your profile may be in your .profile.bash_profile.bashrc.zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATHenvironment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile.

Test that Yarn is installed by running:

yarn --version


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值