I was trying to deploy my Next.js project to Vercel, but the build failed with the following error:
ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json
I realized that Vercel enforces a strict pnpm install
process with the --frozen-lockfile
flag, meaning it expects the pnpm-lock.yaml
file to be perfectly in sync with package.json
.
However, pnpm install
ran without issues locally, indicating a possible mismatch between my lockfile and dependencies.
To resolve this issue, I followed these steps:
I ran the following command to update the lockfile explicitly:
pnpm install --no-frozen-lockfile
This ensured that pnpm-lock.yaml
was correctly regenerated to match the dependencies in package.json
.
Since Vercel pulls the latest committed code, I had to commit and push the updated lockfile:
git add pnpm-lock.yaml
git commit -m "Fix pnpm lockfile mismatch"
git push origin main
After making these adjustments, my deployment on Vercel succeeded without encountering the lockfile error. 🚀
If the above step does not work, you can prevent Vercel from enforcing --frozen-lockfile
by updating your Vercel project settings:
Open Vercel Dashboard
Navigate to Settings > Build & Development
Locate the Build Command section
Set the build command to:
pnpm install --no-frozen-lockfile && pnpm build
If the problem persists, try deleting the lockfile and reinstalling dependencies:
rm pnpm-lock.yaml
pnpm install
Then, repeat Step 2 to commit and push the changes.
After making these adjustments, your deployment on Vercel should succeed without encountering the lockfile error. 🚀
ERR_PNPM_OUTDATED_LOCKFILE
?Vercel enforces strict lockfile consistency with pnpm install --frozen-lockfile
.
If your pnpm-lock.yaml
is outdated (not matching package.json
), the build will fail.
pnpm-lock.yaml
file?Only as a last resort. First, try updating it with pnpm install --no-frozen-lockfile
.
If issues persist, delete and regenerate it with pnpm install
.
pnpm-lock.yaml
whenever dependencies change.pnpm install
locally before pushing new dependencies.frozen-lockfile
on Vercel?Yes, update your build command to:
pnpm install --no-frozen-lockfile && pnpm build
This prevents Vercel from enforcing strict lockfile consistency.