Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9020

Yarnについてまとめ

$
0
0

Yarnとは?

  • 2016年にFacebook社からリリースされたパッケージ管理ツール

  • Node.jsのデフォルト搭載のnpmの代替となるツール

なぜあえてnpmでは無くYarnが使われるのでしょうか?

Yarnのメリット

  • 並列処理によりインストールが高速

  • yarn.lockファイルによる厳密なモジュールのバージョン管理

    • (yarnリリース当初、npmにはpackge-lock.jsonファイルが無かった)
  • npmとの互換性

    • npmと同じpackage.jsonが使える

npmとyarnの主なコマンドの違い

package.jsonの作成

npm
npm init
yarn
yarn init

依存パッケージのインストール

npm
npm i
yarn
yarn

新規パッケージのインストール

npm
npm i <パッケージ名>
yarn
yarn add <パッケージ名>

パッケージのグローバルインストール

npm
npm i <パッケージ名> -g
yarn
yarn global add <パッケージ名>

パッケージのアンインストール

npm
npm uninstall <パッケージ名>
yarn
yarn remove <パッケージ名>

scriptsのスクリプト実行

npm
npm run <スクリプト名>
yarn
yarn <スクリプト名>

Viewing all articles
Browse latest Browse all 9020

Trending Articles