Skip to content

Instantly share code, notes, and snippets.

@IAMOTZ
Created April 29, 2021 17:32
Show Gist options
  • Save IAMOTZ/9b3d0945f9a9518ebc58c802d3156515 to your computer and use it in GitHub Desktop.
Save IAMOTZ/9b3d0945f9a9518ebc58c802d3156515 to your computer and use it in GitHub Desktop.
Fix for CI Error: "Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`."

Error:

CI pipeline buld fails with an error looking like this:

error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Cause:

  • The CI tool is trying to install project dependencies using yarn install --frozen-lockfile
  • Context: The --frozen-lockfile flag tells yarn not to create a yarn.lock file or fail if an update is requried to an existing one. See cli docs
  • Context: This is the default behaviour of many CI toos as it makes a lot of sense to avoid writing to yarn.lock just to run CI builds.
  • In a case where the package list file(package.json) is updated and such update is not reflected(or commited) in the already existing(and commited) yarn.lock, there's no way yarn install --frozen-lockfile would run successfully and as a result the job fails.

Fix:

  • Re-run yarn install on your local and be sure to commit the changes to yarn.lock file. Error should be fixed afterwards.
@fleepgeek
Copy link

Thanks. This was helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment