Skip to content
BENIBIX Learn

Lockfile

Development🛠️ Editors & ToolsDevelopment Environments

Also known as Lock File, package-lock.json, Dependency Lock File, poetry.lock

A file that lists the exact version of each package you use. You keep it in Git.

Think of it like

It is like a photo of a toy you built. Anyone can build it again with the same bricks.

Example

Lucy's app works on her laptop but breaks on the server. The server had no lockfile, so it installed newer versions.

Why it matters

It stops the classic bug where it works on one computer but not another. Every install gets the same code.

Definition

A lockfile is a file that lists the exact version of each package a project uses. That includes the packages those packages need. Your package manager writes it for you, like package-lock.json for npm. When someone else installs the project, they get the very same versions. You commit it to Git with the rest of your code.

Example code

console
$ npm ci
This installs just what the lockfile lists. It stops if the lockfile and package.json do not match.
The lockfile, on the right, lets a new computer get the same ones.

Common mistake

Leaving the lockfile out of Git, or deleting it to fix an error. Both throw away the exact versions you tested.

Key takeaways

  1. 1
    Exact versions. Every package, down to the last one.
  2. 2
    Written for you. The package manager keeps it current.
  3. 3
    Commit it. So every computer installs the same code.

Compare

Learn it properly