Pistachio
Pistachio

Reputation: 1652

Yarn upgrade - Is the new version saved?

Say I have a package.json file in an existing project. In there I have "some-package": "^1.0-01",, however I know that the latest version is 1.0-02

So I do yarn upgrade. However, package.json is not update, and still references the -01 version. The yarn.lock file however shows this:

some-package@^1.0-01:
  version "1.0-02"

Is this expected behavior? When someone else does the yarn command, which version will they get. If they get the latest version, isn't it misleading to show -01 in package.json?

Upvotes: 5

Views: 4382

Answers (1)

nikjohn
nikjohn

Reputation: 21802

According to the documentation here,

yarn upgrade

This command updates all dependencies to their latest version based on the version range specified in the package.json file. The yarn.lock file will be recreated as well.

The tricky part is based on the version range specified in the package.json

This means that if your package.json has defined a particular semver like you've said, upgrade will only upgrade it according to the range defined there, i.e. ^1.0-01 should upgrade to 1.0-02 in both your package.json and yarn.lock files.

Now you've said that this is happening only in your yarn.lock file. Yarn provides a utility for checking for such clashes called check

Could you try running

yarn check

in your repository and tell us your findings?

Upvotes: 5

Related Questions