vercel

Why does my Vercel deployment fail with Module not found: Can't resolve '@/models/Users', even though pnpm run build works locally and the file exist?


I keep getting Can't resolve '@/models/Users' on my NextJS project dashboard on Vercel when deploying changes.

vercel dashboard

But when I run pnpm run build localy, it is successful as shown below.

pnpm run build

I've tried deleting the node_modules but didn't work.

It's expected to work since the file exists.


Solution

  • Double check that the file is actually named Users.ts and not users.ts as Vercel and Git are case-sensitive.

    Try renaming the file to something else, commit and push, then rename it back, that resolves case-related issues.