LoginSignup
1
0

More than 5 years have passed since last update.

yarn <command> と npm <command>

Last updated at Posted at 2018-03-04

はじめに

yarn <command>npm <command>で分かったことをメモ。

TL; DR;

  • yarn <command>
    • yarn -hで出てくるサブコマンド一覧にないものなら、scriptsrun無しで呼べる。
  • npm <command>
    • startscripts.startの中身を実行してくれる
    • その他はnpm runじゃないとダメ。(多分)

以下のようなpackage.jsonがあったとする。

ちょっとした実験

package.json
{
  "name": "hoge",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "echo 'start was called'",
    "build": "echo 'build was called'",
    "hello": "echo 'hello was called'"
  }
}

これに対して、各scriptに対して、yarnnpmrunなしで呼んで見る。
○、×はスクリプトが実行されたかどうか。

script yarn npm
start
build ×
hello ×

まとめ

yarnのほうが短くて便利だと思った。

1
0
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
1
0