LoginSignup
27
34

More than 5 years have passed since last update.

Yarn (yarnpkg) インストール覚書

Last updated at Posted at 2017-02-09

社内向けに Yarn のインストール方法をメモ書きします。

Yarn

Homebrew をインストール

下記をターミナルにコピペして実行してください。
たったそれだけでインストールが完了します。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Yarn をインストール

先ほどの Homebrew を使用して Yarn をインストールします。
下記をコピペして実行してください。

brew update && brew install yarn

npm でもインストール可能

Homebrew がうまくインストールされないよ!という方は、npm でもインストール可能です。

npm install --global yarn

pathを通す

/Users/ユーザー名/ にある、.bash_profile ファイルに下記を追記します。
※なければ新規作成してください。

export PATH="$PATH:`yarn global bin`"

追記できたら、上書き保存しましょう。

Yarn の動作確認

下記のコマンドを実行して、バージョンが表示されれば Yarn のインストール完了です。

yarn -v

Yarn の基本的な使い方

下記のコマンドで package.json に記述されているモジュールを一括インストール可能です。

yarn install

または

yarn

感覚的には npm コマンドと変わらないのですが、一部変更があるので注意が必要です。

モジュールの個別インストール

npmの場合
npm install モジュール名
yarnの場合
yarn add モジュール名

モジュールの個別アンインストール

npmの場合
npm uninstall モジュール名
yarnの場合
yarn remove モジュール名

モジュールの個別アップデート

npmの場合
npm update モジュール名
yarnの場合
yarn upgrade モジュール名

その他のオプション

詳しくは yarn help コマンドで確認してください。

参考サイト

27
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
34