npm WARN old lockfile The package-lock.json file was created with an old version of npm — how to fix
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
Quick fix: Let it finish once with npm install, then commit the updated package-lock.json (now lockfileVersion 2 or 3) so it never happens again. Make sure everyone and CI use npm 7+ (npm -v); an npm 6 user would downgrade the file again.
What it means
This is a warning, not an error. npm 7 introduced a new lockfile format that stores more information per package. When it reads an old v1 lockfile ("lockfileVersion": 1), it fetches the missing metadata from the registry and upgrades the file.
Check which format you have:
grep lockfileVersion package-lock.json
npm -v
The fix-up can take a long time on big projects because it makes registry requests for many packages. If the install fails afterwards, the real error is further down in the output — not this warning.
Fix 1: upgrade the lockfile once and commit it
npm install
git diff --stat package-lock.json
git add package-lock.json
git commit -m "Upgrade package-lock.json to npm 7+ format"
Afterwards lockfileVersion is 2 or 3 and the warning is gone for everybody on npm 7+.
If you want to rewrite only the lockfile without touching node_modules:
npm install --package-lock-only
Fix 2: stop the file flipping back to v1
If the warning keeps coming back, someone (or some CI job) still runs npm 6 and rewrites the lockfile in the old format. Align versions:
node -v && npm -v
npm install -g npm@latest # or upgrade Node, which bundles a newer npm
You can make the requirement explicit in package.json:
"engines": {
"node": ">=18",
"npm": ">=7"
}
This documents the requirement for contributors; also pin the Node version in CI (for example with actions/setup-node and a node-version) so CI never runs npm 6. Engine mismatches in dependencies show up as the EBADENGINE warning.
Fix 3: CI with npm ci
npm ci installs exactly what's in the lockfile and doesn't save changes, so with a v1 lockfile it repeats the slow fix-up on every run. Commit the upgraded lockfile (Fix 1) to make CI fast again.
Fix 4: the fix-up hangs or fails
Because it talks to the registry for many packages, slow or blocked networks show up here:
- Behind a proxy or private registry, check
npm config get registryand your proxy settings. - Timeouts end in errors like ETIMEDOUT or ERR_SOCKET_TIMEOUT.
- As a last resort, regenerate the lockfile from scratch:
rm -rf node_modules package-lock.json
npm install
Regenerating may move dependencies to newer versions allowed by your package.json ranges, so run your tests and review the diff before committing.
Is it safe to ignore?
Yes, functionally. The warning only costs time. But a lockfile that is upgraded on every developer's machine and never committed causes noisy diffs and slow installs, so commit the new format once.
Last updated 2026-12-05.