Upgrading to Sanity 2.35.0 caused a compilation error due to an issue with the auto-id module.

4 replies
Last updated: Oct 24, 2022
I upgraded to 2.35.0 (from 2.34.0) today, but..
✔ Compiling...
Failed to compile.

Error in ./node_modules/@sanity/form-builder/node_modules/@sanity/ui/node_modules/@reach/auto-id/dist/reach-auto-id.esm.js
Module not found: Error: Can't resolve '@reach/utils/use-isomorphic-layout-effect' in '/Volumes/repos/my-project-sanity/node_modules/@sanity/form-builder/node_modules/@sanity/ui/node_modules/@reach/auto-id/dist'
 @ ./node_modules/@sanity/form-builder/node_modules/@sanity/ui/node_modules/@reach/auto-id/dist/reach-auto-id.esm.js 2:0-86

AI Update

This error appears to be a dependency resolution issue in your Sanity Studio v2 project. The module @reach/utils/use-isomorphic-layout-effect can't be found because of how nested dependencies are being resolved in your node_modules folder.

Since I cannot verify this as a documented issue specific to version 2.35.0, I'll provide general troubleshooting steps that typically resolve module resolution problems:

Try these solutions in order:

1. Clean install (most likely to fix the issue)

rm -rf node_modules
rm package-lock.json  # or yarn.lock if using yarn
npm install  # or yarn install

This forces your package manager to rebuild the dependency tree from scratch, which often fixes nested dependency resolution issues.

2. Try different package manager flags

If you're using npm 7 or later, dependency resolution changed. Try:

npm install --legacy-peer-deps

3. Explicitly install the missing package

Sometimes manually installing the dependency helps:

npm install @reach/utils

4. Try a different package manager

Different package managers handle nested dependencies differently. If you're using npm, try yarn or pnpm:

yarn install
# or
pnpm install

Important context about Studio v2:

Studio v2 support ended on December 7, 2023 and is no longer receiving updates or security patches. If you're experiencing dependency issues with v2, this is a strong signal to migrate to Studio v3, which uses a completely different dependency architecture and doesn't rely on the @reach libraries that are causing your current issue.

Studio v3 offers significant improvements including modern build tooling, better TypeScript support, and active ongoing support. While migration requires some work, it's necessary for continued security and feature updates.

yarn why @reach/auto-id
yarn why v1.22.10
[1/4] :thinking_face: Why do we have the module "@reach/auto-id"...?
[2/4] :truck: Initialising dependency graph...
[3/4] :mag: Finding dependency...
[4/4] :aerial_tramway: Calculating file sizes...
=> Found "@reach/auto-id@0.13.2"
info Has been hoisted to "@reach/auto-id"
info Reasons this module exists
  - Hoisted from "@sanity#base#@reach#auto-id"
  - Hoisted from "@sanity#default-layout#@reach#auto-id"
  - Hoisted from "@sanity#desk-tool#@reach#auto-id"
  - Hoisted from "@sanity#desk-tool#@sanity#form-builder#@reach#auto-id"
info Disk size without dependencies: "60KB"
info Disk size with unique dependencies: "256KB"
info Disk size with transitive dependencies: "364KB"
info Number of shared dependencies: 5
=> Found "@sanity/ui#@reach/auto-id@0.16.0"
info This module exists because "@sanity#ui" depends on it.
info Disk size without dependencies: "60KB"
info Disk size with unique dependencies: "256KB"
info Disk size with transitive dependencies: "364KB"
info Number of shared dependencies: 5
npx @sanity/cli versions
@sanity/cli                 2.35.0 (up to date)
@sanity/base                2.35.0 (up to date)
@sanity/cli                 2.35.0 (up to date)
@sanity/color-input         2.35.0 (up to date)
@sanity/components          2.14.0 (up to date)
@sanity/core                2.35.0 (up to date)
@sanity/default-layout      2.35.0 (up to date)
@sanity/default-login       2.35.0 (up to date)
@sanity/desk-tool           2.35.0 (up to date)
@sanity/image-url            1.0.1 (up to date)
@sanity/production-preview  2.33.2 (up to date)
@sanity/rich-date-input      2.0.9 (up to date)
@sanity/vision              2.35.0 (up to date)
Might upgrading auto-id to latest (0.18.0) version work? You seem to be on 0.13.2 in one place and 0.16.0 elsewhere (Sanity UI uses latter per above stats)
Eh, good old
rm -rf node_modules
and a re-install fixed it.

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?