How to also update the package.json version when using yarn update
If you run yarn update
on a package, yarn will update the package and your yarn.lock file. This is totally fine. As long as you check in your lock file, your developers and team will all have the correct versions of libraries when they run yarn install.
However it will not update the package.json with the new semver for the package. I kind of found this annoying, if only for aesthetic reasons I wanted to quickly see which minimum versions of packages I was using in package.json.
To have yarn also update the semver in your package.json there are a couple of options. Essentially you need to add --latest
Using --latest
If you pass yarn the --latest
flag it will update the package.json.
NOTE: this will not respect semver and will update to the latest version. Whatever that might be.
yarn upgrade @graphql-codegen/cli --latest
Using interactive upgrade --latest
If you use the interactive upgrade it will also upgrade the package.json for you
yarn upgrade-interactive --latest
Specify use an exact version --exact
It's a good idea to specify a specific version of the package so that deploying on CI will have the exact same versions as on your dev env. Your lock file will help with this too but being specific with versions is a good idea.
yarn upgrade @graphql-codegen/cli --latest --exact