Safeguard
Security Guides•

You inherited a repo with no lockfile: what to do first?

No lockfile means every install can resolve different versions. Learn how to generate one safely, review the first diff, and make it stick in CI.

Safeguard Security Team
3 min read

Generate a lockfile on a clean machine, review what it resolved, commit it on its own, and switch CI to a frozen install. Without a lockfile, each install resolves versions from the ranges in the manifest, so two builds of the same commit can differ. The first lockfile is a baseline, so treat it as a review event.

Why it is a problem

The npm documentation says package-lock.json describes the exact tree that was generated so subsequent installs produce identical trees regardless of intermediate dependency updates, and that it is meant to be committed. The Cargo Book makes the same argument for Cargo.lock: builds made on different days could get different commits, and reproducible builds are the goal. A repo without that file has no record of what was actually shipped.

First-day plan

  1. Check it is really missing. Look in ignore files. Some repos hide the lockfile by accident.
  2. Ask why. There may be a reason, such as a library workflow. Ask the owner before changing anything.
  3. Use a clean checkout. Install from the manifest on a clean machine or container so local leftovers do not leak in.
  4. Run the install to generate the file. Use the standard command for your ecosystem.
  5. Review the result. Skim the resolved versions of direct dependencies. Run an audit and note what is flagged.
  6. Commit the lockfile alone, in a pull request that changes nothing else, with a description of what you did.
  7. Switch CI to the frozen install, such as npm ci for Node, which errors if the lock and manifest disagree.

Handle the first audit calmly

Expect findings. The lockfile did not create them, it exposed them. Do not fix everything in the same pull request. Record the findings, open tickets, and fix in small changes. If you want to know which matter, check what is reachable and exposed before ranking them.

Set the rule going forward

RuleWhy
Lockfile changes ship with manifest changesKeeps the pair in sync
CI uses frozen installDrift fails loudly
Lockfile diffs get reviewedNew transitive packages are visible
Updates happen on a scheduleVersions move on purpose

See npm ci failures from lockfile drift and our guide to onboarding repositories to scanning in waves.

Where Safeguard fits

Safeguard can do the inventory and watching for you. Its SBOM and dependency scanning lists what a repository actually pulls in, reachability analysis helps separate reachable findings from noise, and policies can gate a pull request. You can try a free scan on a repository to see the output.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a baseline scan is followed by ongoing checks as new advisories appear.

Quick check

Is it ever right not to commit a lockfile?

Some library projects choose that. Follow your tool's docs and the owner's reasoning, and write the decision down.

Should I upgrade everything while I am at it?

No. Create the baseline first, then update in small, reviewed steps.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.