LoginSignup
81
56

More than 5 years have passed since last update.

yarn run が便利

Last updated at Posted at 2017-03-22

みなさん、 Yarn 使ってますか。

yarn <subcommand> はほぼ npm <subcommand> と互換性があり、そうでない(使い方が違う)コマンドについてはチートシート記事があったりするのですが、

あえて yarn runnpm run とは違うぞと申し上げたい。というのも

[script] can also be any locally installed executable that is inside node_modules/.bin/.

だからです。つまり、

$ yarn run webpack

を実行すると

$ node_modules/.bin/webpack

を実行するのと同じ、または

package.json
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "webpack": "webpack"
  },

のような冗長な項目を足した上で

$ npm run webpack

を実行するのと同じ効果がある。

これっていいよね。 Bundler とか Composer 的。

81
56
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
81
56