javascriptnpmyarnpkgpackage-managerslockfile

Lockfile explanation, what exactly every line mean? yarn.lock


I wondering what exactly every line mean? I had some problems with packages, because of dependencies in my project.

Firstly after updating nuxt from 1x to 2x all test began to fail. After hours of diging in web I noticed that I have 2 version of

chokidar dependencies

which has diffrent watchpack version, so I lock one package with

resolutions in my package file.

It was watchpack ^2.0.0-beta.7 And all tests starts to work!

But unfortunately developer mode stopped to support hot reload... And starts to crashing.

So I tried to lock chokidar to version "^3.0.2" and now everything is just fine!

But I start to wondering how everything works in this file Because after locking that chokidar all problems gone!

chokidar dependencies What exactly that line mean? Which chokidar being used? Both? First? Second? Or even here

chalk dependencies

Some depen. of depenc, with 7 versions!


Solution

  • As I understand it (correct me if I'm wrong), the first line lists all the dependencies, so you have e.g. 7 packages that depend on a certain version of chalk. The second line lists the version that is 'chosen' by Yarn to be installed, it satisfies the criteria above. Example: Chokidar is at 3.1.1 because the criteria specify that one package needs it to be greater than 2.0.2, and one needs it to be greater than 3.0.2. Since 3.1.1 satisfies both it is used. If one of the criteria would be 'exactly 3.0.2', the lines would be split and both versions would be included in the lockfile.

    The third line is the URL to the package, with a hash. The fourth is a hash as well, used for verifying the package when it is downloaded when you run yarn install.

    If Yarn cannot find one version that satisfies all dependencies, it will split the entries into groups, and get a version to match each group's criteria.

    So as for your second question: it's only using one version of Chokidar: 3.1.1

    For a generic explanation, see https://yarnpkg.com/lang/en/docs/yarn-lock/