Mac安裝 yarn

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離線安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章