Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn upgrade - Is the new version saved?

Tags:

yarnpkg

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?

like image 680
Pistachio Avatar asked Oct 12 '16 18:10

Pistachio


People also ask

How do I upgrade my yarn package to latest version?

just run yarn upgrade-interactive --latest and select packages you want to update using space button and press the enter to update.

Does yarn upgrade change package json?

Running yarn upgrade without any modifiers does not update package. json . If we run yarn upgrade without any flags, it will install the latest version that matches the version pattern indicated by package. json .

Does yarn install multiple versions of the same package?

With npm or yarn, you can install a package under a custom alias. This enables you to install multiple versions of a package in the same project.

Does yarn install update dependencies?

yarn install is used to install all dependencies for a project. The dependencies are retrieved from your project's package. json file, and stored in the yarn. lock file.


1 Answers

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?

like image 135
nikjohn Avatar answered Jan 12 '23 00:01

nikjohn