How to fix npm ERR! code ELOCKVERIFY in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 140 views

The ELOCKVERIFY error occurs when package-lock.json and package.json are out of sync. This ensures reproducible builds by detecting when dependencies have changed.

Quick fix

Fixes npm ERR! code ELOCKVERIFY

rm package-lock.json
npm install
  1. Regenerate package-lock.json
  2. Use npm install instead of ci
  3. Check for merge conflicts
  4. Verify npm versions match
npm โ€” error
rm package-lock.json
npm install
npm ERR! code ELOCKVERIFY

What this error means

npm ci (and npm install with certain flags) verifies that package-lock.json matches package.json. If they're out of sync - different versions, missing packages, or extra packages - npm refuses to proceed. This verification ensures reproducible builds. The lock file should exactly match what package.json specifies, and any changes should be intentional and committed together.

Typical symptoms

  • npm ci fails with lock verification error
  • package-lock.json outdated
  • Dependencies added but lock not updated
  • Lock file committed by different npm version
  • Merge conflict in lock file not resolved
  • Lock file manually edited incorrectly

Common causes

  1. package.json modified without npm install
  2. Lock file from different npm version
  3. Merge conflict resolution errors
  4. Manual lock file edits
  5. npm install not run after package.json change
  6. Dependency version changed in package.json

How to fix "npm ERR! code ELOCKVERIFY"

1Regenerate package-lock.json

Create fresh lock file:

bash
rm package-lock.json
npm install

This creates a new lock file matching package.json.

2Use npm install instead of ci

npm install updates the lock file:

bash
npm install

# Then commit the updated lock file
git add package-lock.json
git commit -m "Update package-lock.json"
3Check for merge conflicts

Look for conflict markers:

bash
grep -n "<<<<<<" package-lock.json
grep -n "======" package-lock.json
grep -n ">>>>>>" package-lock.json

Resolve by regenerating lock file.

4Verify npm versions match

Different npm versions may create different locks:

bash
# Check your version
npm --version

# Check version in lockfileVersion field
cat package-lock.json | grep lockfileVersion
5Update CI npm version

Match CI to local npm:

yaml
# GitHub Actions
- uses: actions/setup-node@v4
  with:
    node-version: "20"
    cache: "npm"
6Fix package.json changes

Ensure lock matches package.json:

bash
# See what differs
npm ls

# After package.json changes, always:
npm install
git add package.json package-lock.json
git commit -m "Add/update dependency"

Advanced notes

Always commit package-lock.json to version control. Use npm ci in CI/CD for reproducible builds. Different npm versions (especially major versions) may generate incompatible lock files. Consider adding npm version to .nvmrc or engines field. In monorepos with workspaces, workspace lock file must be in sync with all workspace package.json files.

Frequently asked questions

What does "npm ERR! code ELOCKVERIFY" mean?
json. If they're out of sync - different versions, missing packages, or extra packages - npm refuses to proceed. This verification ensures reproducible builds.
How do I fix "npm ERR! code ELOCKVERIFY"?
The ELOCKVERIFY error occurs when package-lock.json and package.json are out of sync. This ensures reproducible builds by detecting when dependencies have changed.
What causes "npm ERR! code ELOCKVERIFY"?
package.json modified without npm install Lock file from different npm version Merge conflict resolution errors
Is the "npm ERR! code ELOCKVERIFY" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading