# Lockfile

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

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Lock File, package-lock.json, Dependency Lock File, poetry.lock

## Think of it like

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

## 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

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

## Example code

```console
$ npm ci
```

This installs just what the lockfile lists. It stops if the lockfile and package.json do not match.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Package Manager](https://learn.benibix.com/term/development/package-manager)
- [Dependency](https://learn.benibix.com/term/development/dependency)
- [npm](https://learn.benibix.com/term/development/npm)
- [Software Package](https://learn.benibix.com/term/development/software-package)
- [Version Control](https://learn.benibix.com/term/development/version-control)
- [package.json](https://learn.benibix.com/term/development/package-json)
- [Version Pinning](https://learn.benibix.com/term/development/version-pinning)

## Told apart from

- [Lockfile vs Version Pinning](https://learn.benibix.com/compare/lockfile-vs-version-pinning): People think a lockfile and a pinned version are the same thing, and they are not. You pin a version by hand, in the list of packages you asked for. A lockfile is written by the tool. It holds the exact version of every package, even the ones your packages pulled in. So a project can ask for ranges and still get the same install each time.

## Taught in

- [Lockfiles and Version Pinning](https://learn.benibix.com/learn/development-tools/lockfiles-and-version-pinning): Coding Tools, 10/13

![A package registry, drawn as a big shelf of named boxes, on the left. An arrow marked install runs to a package manager in the middle. It writes two things into the project on the right: the packages themselves, and a lockfile that lists the exact version of each one, such as left-pad 1.3.0. A second computer reads the same lockfile and gets the same versions.](https://learn.benibix.com/diagrams/dev-package-flow.svg)

---

Source: https://learn.benibix.com/term/development/lockfile
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
