Skip to content

Instantly share code, notes, and snippets.

@valorad
Last active January 22, 2018 12:09
Show Gist options
  • Save valorad/5d41ad6580ba8b7429abc762032c7c36 to your computer and use it in GitHub Desktop.
Save valorad/5d41ad6580ba8b7429abc762032c7c36 to your computer and use it in GitHub Desktop.
安装yarn的正确姿势(有版本管理器如nvm存在时) How to install Yarn when node is under version management (such as nvm)
# 开启yarn global
# 添加到 ~/.bashrc 最后
# add yarn global
export PATH=$PATH:$HOME/.yarn/bin
# 参考的是 1.0.2 版本的Yarn
# Ubuntu
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
sudo apt update
# 安装依赖项
sudo apt install libuv1
sudo apt install yarn --no-install-recommends
# Fedora
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
sudo dnf update
# 安装依赖项
sudo dnf install libuv
sudo dnf install yarn --downloadonly
cd /var/cache/dnf/yarn-xxxxxxxxxxxxx/packages
sudo rpm -i --nodeps ./yarn-x.xx.x-x.noarch.rpm
# Arch
sudo pacman -S c-ares http-parser libuv openssl
sudo pacman -Sdd yarn
# macOS
# 需要首先安装xcode或其命令行工具。在App Store中安装xCode,或执行下面的命令安装xCode命令行工具。
xcode-select --install
# 然后安装homebrew (参考的是v1.2.4)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 安装其中一个依赖: icu4c
brew install icu4c
# 安装yarn
brew install yarn --ignore-dependencies
# Windows
#直接安装.msi文件即可。

注意在Windows环境下,virtualBox中使用yarn 安装到共享文件夹,会Boom:

An unexpected error occurred: "EROFS: read-only file system, symlink '../../../bless/bin/blessc' -> '.../node_modules/apostrophe/node_modules/.bin/blessc'".

这种情况下就不要让yarn创建软链接,而是直接将文件拷进node_modules.

下面是正确的命令

yarn install --no-bin-links

参考:yarnpkg/yarn#929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment