Centos7安装yarn

Centos7安装yarn

设置Yarn仓库

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

如果还没有安装node.js,再设置一下设置node仓库

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

开始始安装

sudo yum install yarn
## OR ##
sudo dnf install yarn

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

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

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

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

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

yarn --version

国内镜像加速

yarn config set registry https://registry.npm.taobao.org

使用 Yarn 安装依赖

SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass yarn

在 yarn 命令前添加 SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass 的目的是告诉 yarn 到淘宝的镜像去下载 node-sass 二进制文件。

安装过程可能会报

error cross-env@7.0.2: The engine "node" is incompatible with this module. Expected version ">=10.14". Got "8.17.0"
error Found incompatible module.

执行如下命令,然后重新安装

yarn config set ignore-engines true
原文地址:https://www.cnblogs.com/technicianafei/p/14765531.html