Module not found error after Sanity upgrade: Can't resolve '../../utils/patches

15 replies
Last updated: Jan 28, 2026
Just did an sanity upgrade and getting these errors ... anyone seen this or have any ideas? I've done several upgrades before no problem. I am using OOTB studio.
✔ Checking project info
✔ Clearing output folder (7ms)
✖ Building Sanity

Error: Errors while building:
./node_modules/@sanity/form-builder/lib/sanity/uploads/uploaders.js
Module not found: Error: Can't resolve '../../utils/patches' in '/home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/lib/sanity/uploads'
resolve '../../utils/patches' in '/home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/lib/sanity/uploads'
  using description file: /home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/package.json (relative path: ./lib/sanity/uploads)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/package.json (relative path: ./lib/sanity/uploads)
    using description file: /home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/package.json (relative path: ./lib/utils/patches)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/lib/utils/patches doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /home/x/dev/projects/c4c/climbing4change-cms/node_modules/@sanity/form-builder/lib/utils/patches.js doesn't exist
      .jsx
...
AI Update

This looks like a classic case of mixed or corrupted dependencies after an upgrade. The @sanity/form-builder package was a standalone package in Sanity Studio v2, but it's been fully integrated into the core sanity package since Studio v3. This error usually means you have remnants of old packages in your node_modules.

Here's how to fix it:

1. Clean install (most likely solution):

rm -rf node_modules
rm package-lock.json  # or yarn.lock / pnpm-lock.yaml
npm install

2. Check your package.json:

Make sure you don't have @sanity/form-builder explicitly listed as a dependency. In Studio v3+, you should only have:

{
  "dependencies": {
    "sanity": "^3.x.x"  // or whatever your version is
  }
}

If @sanity/form-builder is there, remove it and reinstall.

3. Check for outdated plugins:

Sometimes custom plugins or older third-party packages still depend on @sanity/form-builder. Run:

npm ls @sanity/form-builder

If anything shows up, those packages need updating to be compatible with Studio v3+.

4. Verify your Studio version:

  • If you have a sanity.json file in your project root, you're still on Studio v2 and need to migrate to v3
  • Make sure you're on Node.js 18+ (Node.js 20+ is required for Studio v4)

Why this happens:

The @sanity/form-builder package hasn't been maintained since Studio v3 was released. When upgrading, if the old package isn't fully removed, webpack/bundler tries to resolve the old internal file structure (like ../../utils/patches) which no longer exists. A clean install usually clears this up completely.

If you're still stuck after trying these steps, check if any custom input components in your schema are importing directly from @sanity/form-builder - those would need to be updated to import from sanity instead.

Show original thread
15 replies

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?