innovationanna.blogg.se

Package json caret
Package json caret











This means that yarn.lock can actually have a version of 7.3.1 of a package while package.json has it set to ^7.2.0. The yarn.lock is a huge file that contains the complete dependency tree of all currently installed packages in your project. On the other hand eslint-plugin-react-hooks is multiple versions behind the latest but the wanted version is still the current one. If you want to dig deeper into the prepending you can read more here.Īs you see in the above image eslint is currently on 7.2.0 and the wanted version is 7.3.1.

package json caret

So in this case version ^7.2.0 can be upgraded to 7.3.1 but not to 8.0.0 for example. Npm packages are using Semantic Versioning (semver) so a MAJOR version is a bump that is changing the first number of the version. This means that we can upgrade to all upcoming versions of that package as long as it is not a MAJOR update.

#Package json caret install

Before presenting a solution let's explain a bit why it works like this.Īs default when you install an npm package with yarn add the version of that package in package.json is prepended with a caret, like ^7.2.0. This is usually not a big problem because you have a file called yarn.lock in your root directory that keeps track of all your installed versions but if you are a perfectionist like me, you also want the package.json file to reflect what versions used in the project. Something that those coming from using npm update finds out is that the yarn equivalent doesn't update the package.json with the new versions. It updates all packages to their latest backwards-compatible version. Updating dependencies in an npm project is pretty straight forward and easy to do with the command yarn upgrade.











Package json caret