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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM