Issue with build process after making a small change in Vercel deployment

3 replies
Last updated: Jul 3, 2023
This morning I deployed a couple of changes to vercel and the build process worked. I made one small change (added an icon) and then re-committed. All of my builds are failing now with the error:
Failed to compile.
./node_modules/@hookform/resolvers/dist/resolvers.mjs
Attempted import error: 'set' is not exported from 'react-hook-form' (imported as 'i')
Import trace for requested module:
./node_modules/@hookform/resolvers/dist/resolvers.mjs
/node_modules/@hookform/resolvers/yup/dist/yup.mjs
/node_modules/sanity-plugin-media/lib/index.esm.js
/sanity.config.js
/app/(admin)/studio/[[...index]]/page.js

I am running Sanity Studio from the App directory.

Current version of next-sanity is 5.1.0

The failed builds coincide with the exact time that Next v13.4.8 was released.

Any suggestions other than starting from scratch again with the implementation of Studio? Anybody else experiencing this?
AI Update

This is a classic dependency version conflict issue between sanity-plugin-media and react-hook-form. The error occurs because @hookform/resolvers (used by the media plugin) is trying to import a set function that doesn't exist in older versions of react-hook-form.

The timing with Next.js 13.4.8's release is likely coincidental - what probably happened is that your lockfile got regenerated during the build, pulling in newer versions of dependencies that are incompatible with each other.

Here's how to fix it:

  1. Update react-hook-form to a compatible version (v7.43.0 or higher includes the set export):
npm install react-hook-form@latest
  1. Ensure @hookform/resolvers is compatible:
npm install @hookform/resolvers@latest
  1. Clear your lockfile and node_modules to ensure clean dependency resolution:
rm -rf node_modules package-lock.json
npm install
  1. If you're still having issues, check your package.json for any version constraints that might be preventing the update. You want:
  • react-hook-form: ^7.43.0 or higher
  • @hookform/resolvers: ^3.0.0 or higher
  1. Alternative: Switch to the official media plugin - If sanity-plugin-media continues to cause dependency issues, consider using Sanity's built-in asset management features or look for more actively maintained alternatives.

Why this happened: The sanity-plugin-media package has specific peer dependency requirements. When your build process ran, it likely resolved to incompatible versions of react-hook-form and @hookform/resolvers. The set utility was added to react-hook-form in v7.43.0, but older versions don't have it.

For Vercel specifically: Make sure to clear Vercel's build cache after updating your dependencies. You can do this in your project settings under "Deployments" → click the three dots menu → "Redeploy" with "Use existing Build Cache" unchecked.

You definitely don't need to start from scratch - this is purely a dependency version mismatch that can be resolved by aligning your package versions.

Hi
user V
. I suspect this may be related to an unintended breaking change in a dependency of
sanity-plugin-media
. Can you please try pinning your version to
2.0.5
? You can do this in your package.json by removing the caret from the version (e.g.,
"sanity-plugin-media": "2.0.5"
), then deleting node_modules and your lock file and re-installing with
npm i
.
Hi
user A
,
Thanks for such a prompt reply and bailing me out on this. Your suggestion worked and I have successfully re-deployed to Vercel. I ended up removing my admin folder that has the studio pages within it from the push to the repo and subsequent pipeline to vercel. That helped me to get my changes deployed. I was then able to do as you suggested, prove it worked, then redeploy with my admin folder, and then access the studio on the production site.
Great! Glad to hear it, Brett. The team is working on a resolution.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?