Should I commit the yarn.lock file and what is it for?

后端 未结 9 1982
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 07:03

Yarn creates a yarn.lock file after you perform a yarn install.

Should this be committed to the repository or ignored? What is it for?

9条回答
  •  忘掉有多难
    2020-12-04 07:20

    Depends on what your project is:

    1. Is your project an application? Then: Yes
    2. Is your project a library? If so: No

    A more elaborate description of this can be found in this GitHub issue where one of the creators of Yarn eg. says:

    The package.json describes the intended versions desired by the original author, while yarn.lock describes the last-known-good configuration for a given application.

    Only the yarn.lock-file of the top level project will be used. So unless ones project will be used standalone and not be installed into another project, then there's no use in committing any yarn.lock-file – instead it will always be up to the package.json-file to convey what versions of dependencies the project expects then.

提交回复
热议问题