11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

yarnを使っているプロジェクトの時のみnpm installをyarnに切り替える

Last updated at Posted at 2016-12-26

yarnを使ってないプロジェクトで雑にyarn叩いてオアアってなりたくないので、yarn.lockがある場合のみnpm installの代わりにyarnを叩くcliツール書いた。

$  npm install --global prioritize-yarn

単純なnpmのラッパなので、.bashrcまたは.zshrcに以下のようにaliasして使うと便利。

alias npm=prioritize-yarn

するとyarn.lockがあるプロジェクトでは、npm installを叩くとyarnが実行されるようになる。

❯ npm install
yarn install v0.18.1
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
✨  Done in 2.25s.

ない場合は普通のnpm installのまま動作する。
他全てのコマンドには干渉しないので、install以外はnpmと同様に動作する。

はやく全てのプロジェクトがyarnに切り替わるといいですね。
akameco/prioritize-yarn: If the project has yarn.lock, change npm install to yarn.

11
7
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
11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?