Hi there,
I’m a Pro plan user experiencing a persistent build failure on Vercel with the error: Cannot find module '@hookform/resolvers/zod'
. This issue is specific to Vercel deployments; my project builds and runs perfectly fine locally using pnpm
.
Error Details:
The error consistently points to the same import:
- File:
frontend/app/(authenticated)/dashboard/question-sets/[setId]/manage/page.tsx
- Line 15:
import { zodResolver } from "@hookform/resolvers/zod";
- This
zodResolver
is then used on line 70:resolver: zodResolver(addMemberSchema),
Relevant Package Versions (from pnpm-lock.yaml
/ package.json
):
@hookform/resolvers
:5.0.1
(specifier^5.0.1
)react-hook-form
:7.56.4
(specifier^7.56.2
)zod
:3.25.28
(specifier^3.24.3
)next
:15.3.2
(from Vercel build logs)- Package Manager:
pnpm
(Vercel auto-detects and uses it due topnpm-lock.yaml
) - Node.js on Vercel:
22.15.1
(selected major version)
Troubleshooting Steps Attempted (without success on Vercel):
I’ve gone through extensive troubleshooting, including:
- Ensuring Correct Paths: All internal aliases (
@/
) were previously converted to relative paths in the affected file and related components. - Forcing Cache Re-evaluation: Made minor
package.json
modifications (like adding a comment) to try and bust Vercel’s cache. - Downgrading
@hookform/resolvers
: Temporarily downgraded to^2.9.11
as per suggestions for common working setups, then updatedpnpm-lock.yaml
. - Reverting and Refreshing Dependencies: Reverted
@hookform/resolvers
to^5.0.1
and explicitly re-added it andzod
usingpnpm add @hookform/resolvers@latest zod@latest
to ensure a pristinepnpm-lock.yaml
. tsconfig.json
Path Mapping: Added an explicit path mapping infrontend/tsconfig.json
undercompilerOptions.paths
:"@hookform/resolvers/zod": [ "./node_modules/@hookform/resolvers/zod" ]
- Multiple Commits & Redeploys: Each of these changes was committed (latest relevant commit for this state:
8e22015
) and pushed, triggering new Vercel builds, all of which failed with the same error. - Clearing Vercel Build Cache: I have not yet manually cleared the Vercel build cache via the dashboard, as I wanted to post here first in case there’s a known issue or a different recommended approach. This will be my immediate next step after posting.
Despite these efforts, the Vercel build environment consistently fails to resolve this specific nested module export, which is a standard import and works without issue in my local pnpm
environment.
Could there be a known issue with pnpm
and how Vercel handles module resolution for packages structured like @hookform/resolvers
? Or any other insights into why Vercel might be unable to find this module when it’s clearly defined in the dependencies and works locally?
Any help or suggestions would be greatly appreciated!
Thanks,
p-riemer