Lockfile

All ecosystems
Definition

A lockfile is an automatically generated file that records the exact resolved versions of every direct and transitive dependency in your project. When you run npm install for the first time, npm picks the latest compatible version of every package and writes those choices to package-lock.json. The next time anyone installs — on a different machine or in CI — npm reads the lockfile and installs those exact same versions.

Why lockfiles matter for security

Without a lockfile, two developers running npm install on the same project on different days might get different transitive dependency versions — because a new version of a transitive package was published between the two installs. One version might be vulnerable, the other not.

With a lockfile committed to your repo, everyone gets the same versions. Your CI environment and your local machine match. Dependency changes are explicit and reviewable in git diffs.

Lockfiles by ecosystem

Always commit your lockfile

Some projects have .gitignore entries that exclude lockfiles — this is almost always a mistake. The lockfile is critical for reproducible builds and security scanning. PackageFix can scan transitive dependencies when you provide the lockfile alongside your manifest — drop both files into the scanner for the most complete vulnerability coverage.

Check your dependencies for CVEs, CISA KEV entries, and supply chain risks.

Open PackageFix →

Free · No signup · No CLI · Runs in your browser

Common questions

Should I commit my lockfile to git?
Yes, always — for applications. The lockfile ensures everyone on your team and your CI environment get identical dependency versions. Not committing it is a common mistake that leads to 'works on my machine' problems and security scanning gaps.
What's the difference between package.json and package-lock.json?
package.json lists what you want — ranges like ^4.17.0. package-lock.json records what you actually got — the exact version that resolved, like 4.17.21. The lockfile is the source of truth for what's actually running.
Does PackageFix use the lockfile?
Yes. Drop your lockfile alongside your manifest into PackageFix for transitive dependency scanning. Without the lockfile, PackageFix only scans direct dependencies. With it, every transitive package is checked against OSV and CISA KEV.
What happens if my lockfile and package.json are out of sync?
npm will warn you and refuse to run npm ci. Run npm install to regenerate the lockfile, review the diff, then commit. PackageFix's /error/package-json-missing-lockfile page covers this specific error.

Related guides