LoginSignup
17
8

More than 5 years have passed since last update.

yarn.lockって何?

Last updated at Posted at 2017-10-19

npmで言うところのshrinkwrap

shrinkwrapって何?

インストールしたnodeモジュールのバージョンを固定することができる。

$ npm shrinkwrap

これをたたくと、npm-shrinkwrap.jsonが作成される。
中身はこのような感じになっている。

{
  "name": "test",
  "version": "1.0.0",
  "dependencies": {
    "jquery": {
      "version": "3.1.0",
      "from": "jquery@3.1.0",
      "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.1.0.tgz"
    },
    "jquery-ui": {
      "version": "1.12.1",
      "from": "jquery-ui@1.12.1",
      "resolved": "https://registry.npmjs.org/jquery-ui/-/jquery-ui-1.12.1.tgz"
    }
  }
}

npm-shrinkwrap.jsonの中に記述されているものは、$ npm updateコマンドを叩いてもアップデートされない。

これと同様の事をyarn.lockは行ってくれる。

yarn.lock

# 中身はこんな感じ
$ head yarn.lock
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
acorn-jsx@^3.0.0:
  version "3.0.1"
  resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
  dependencies:
    acorn "^3.0.4"

acorn@^3.0.4:
  version "3.3.0"

shrinkwrapとの違いは、
デフォルトで生成されるので簡単に利用できる
各モジュールがソートされており構成管理が容易

理解できました。

参考:
npmでバージョンをnpm shrinkwrapで固定してさらにバージョンアップデートする方法
yarnがnpmと何が違うのか試してみた

17
8
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
17
8