目的
rails6のアプリケーションを作成した際にyarnのインストールが必要だったため、yarnについて簡単にまとめた
yarnとは
- npmと同じで、nodeのパッケージ管理マネージャー
- rails6ではWebpackerを標準で使い、Webpackerはyarnを使うのでインストールが必要になる。
コマンド使用方法
初期化
# packeage.json作成
yarn init
インストール
yarn add パッケージ名
yarn add パッケージ名@x.y.z
# devDependenciesにインストール
yarn add パッケージ名 -dev
# グローバルインストール
yarn add global パッケージ名
# すべてインストール
yarn
アップデート
yarn upgrade パッケージ名
yarn upgrade
アンインストール
yarn remove パッケージ名
実行
yarn パッケージ名
比較表
コマンド | npm | yarn |
---|---|---|
初期化 | npm init | yarn init |
インストール | npm i | yarn add |
アップデート | npm update | yarn upgrade |
アンインストール | npm remove | yarn remove |
実行 | npx react パッケージ名 | yarn パッケージ名 |