I installed a package with yarn add --dev
, run its setup process and during it, the package installed several other packages and added those to package.json
(in devDependencies
), I assume with npm. Great, but now my yarn.lock
is out of sync.
What is the correct, non-manual way of syncing yarn.lock
to the current state of package.json
?
Edit: yarn check
shows the missing packages as:
error Lockfile does not contain pattern: <package>@<version>
But it doesn't add them.
Run yarn install , or just yarn . The lock file is updated in its entirety on any change to dependencies, i.e. when you run a yarn command. From the Yarn docs: Your yarn.
Every time a module is added, npm and Yarn create (or update) a package-lock. json and yarn. lock file respectively. This way, you can guarantee another machine installs the exact same package, while still having a range of allowed versions defined in package.
It is highly recommended you commit the generated package lock to source control: this will allow anyone else on your team, your deployments, your CI/continuous integration, and anyone else who runs npm install in your package source to get the exact same dependency tree that you were developing on.
Out-of-Sync Package.lock files are out of sync. For this, you could simply run yarn install and that should resolve the issue.
Run yarn install
, or just yarn
.
The lock file is updated in its entirety on any change to dependencies, i.e. when you run a yarn command.
From the Yarn docs:
Your yarn.lock file is auto-generated and should be handled entirely by Yarn. As you add/upgrade/remove dependencies with the Yarn CLI, it will automatically update your yarn.lock file. Do not edit this file directly as it is easy to break something.
(Emphasis my own)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With