Lockfiles
A lockfile is a file that records the exact, pinned versions of every dependency (including transitive dependencies) required by a software project, ensuring that the same versions are installed consistently across different environments. In package management contexts, lockfiles prevent unexpected version changes when dependencies are installed. They are a key control for reproducible builds and supply chain integrity.
In package management and build systems, a lockfile is a metadata artifact that enumerates specific pinned versions of all direct and transitive third-party dependencies resolved at a point in time. By capturing the full resolved dependency graph with exact version identifiers (and typically integrity hashes), a lockfile enables deterministic installation, meaning that any subsequent install operation reproduces the same dependency set regardless of upstream registry changes or new releases. Committing lockfiles to source control is a recommended practice because it makes the resolved dependency graph auditable and reviewable. Lockfiles are distinct from manifest files (such as package.json or requirements.txt), which typically specify version ranges rather than exact resolved versions. Note that a lockfile records versions resolved at generation time; it does not by itself detect or prevent the introduction of malicious packages, and it does not guarantee integrity unless the tool also validates cryptographic hashes at install time.
Why it matters
Lockfiles are a foundational control for reproducible builds and software supply chain integrity. Without a lockfile, each fresh installation of a project's dependencies resolves versions according to the ranges specified in the manifest file, which means a dependency can silently upgrade to a new release between environments or over time. This silent drift can introduce regressions, behavioral changes, or vulnerabilities without any corresponding change in the project's source code or manifest, making the root cause difficult to identify.
Who it's relevant to
Inside Lockfiles
Common questions
Answers to the questions practitioners most commonly ask about Lockfiles.