How to fix npm ERR! code ELOCKVERIFY in npm
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- Regenerate package-lock.json
- Use npm install instead of ci
- Check for merge conflicts
- Verify npm versions match
rm package-lock.jsonnpm installnpm 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
- package.json modified without npm install
- Lock file from different npm version
- Merge conflict resolution errors
- Manual lock file edits
- npm install not run after package.json change
- Dependency version changed in package.json
How to fix "npm ERR! code ELOCKVERIFY"
Create fresh lock file:
rm package-lock.json
npm installThis creates a new lock file matching package.json.
npm install updates the lock file:
npm install
# Then commit the updated lock file
git add package-lock.json
git commit -m "Update package-lock.json"Look for conflict markers:
grep -n "<<<<<<" package-lock.json
grep -n "======" package-lock.json
grep -n ">>>>>>" package-lock.jsonResolve by regenerating lock file.
Different npm versions may create different locks:
# Check your version
npm --version
# Check version in lockfileVersion field
cat package-lock.json | grep lockfileVersionMatch CI to local npm:
# GitHub Actions
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"Ensure lock matches package.json:
# 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
- ๐npm Official Documentation
- ๐
- ๐