Mac安装 yarn

Mac安装 yarn

  • Mac安装yarn
  • 一、按照提示安装gcc
  • 二、解决gcc错误的方法
  • 三、安装 yarn
  • 四、配置VPN后,再次安装 yarn
  • 五、下载 yarn的 tar.gz包,进行离线安装。

Mac安装yarn

Mac升级到10.15.4之后,Xcode也升级到Version 11.4.1 (11E503a),终端下执行 brew install yarn 进行 yarn安装,最后报错gcc错误。

Error: An exception occurred within a child process:
  CompilerSelectionError: gcc cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

一、按照提示安装gcc

既然gcc错误,直接安装gcc
执行 brew install gcc
错误如下:

$ brew install gcc
Updating Homebrew...
Warning: Building gcc from source:
  The bottle needs the Xcode CLT to be installed.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: An exception occurred within a child process:
  CompilerSelectionError: gcc cannot be built with any available compilers.
Install GNU's GCC:
  brew install gcc

so,度娘试试看:

原因是 在从App Store上下载Xcode后,默认是不会安装Command Line Tools的.

二、解决gcc错误的方法

更新一下Xcode,终端下执行指令:

xcode-select --install

执行结果如下:

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

三、安装 yarn

$ brew install yarn
Updating Homebrew...
==> Downloading https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws
#                                                                          2.8%
curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "yarn"
Download failed: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz

网速问题,那么,配置VPN吧。
如果没有VPN的话,参考第五步。

四、配置VPN后,再次安装 yarn

$ brew install yarn
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
feedgnuplot            geoipupdate            mariadb                repo
fonttools              glooctl                [email protected]

==> Downloading https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/4997064
######################################################################## 100.0%
  /usr/local/Cellar/yarn/1.22.4: 14 files, 5MB, built in 5 minutes 1 second

五、下载 yarn的 tar.gz包,进行离线安装。

(PS:没有尝试过,暂时不知道是否好用)
1、yarn的 tar.gz包下载地址:
https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz

2、离线安装参考文章:
https://www.cnblogs.com/luguiqing/p/11553067.html

参考文章:

1、https://www.cnblogs.com/qyf404/p/how_install_gcc_in_mac.html

2、yarn离线安装

你可能感兴趣的:(Mac使用技巧,yarn,mac安装yarn)