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.
Fixes npm ERR! code ELOCKVERIFY
rm package-lock.json
npm installrm package-lock.jsonnpm installnpm ERR! code ELOCKVERIFY
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.
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"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.