Error after updating sanity/cli 3.35.1 to 3.35.2: Cannot read properties of undefined (reading 'div')

12 replies
Last updated: Jan 28, 2026
Hi there!
I run into this error once I’ve updated the sanity/cli from 3.35.1 to 3.35.2:

> Error reading “/Users/xxxx/xxxx/studio/sanity.cli.ts”: Cannot read properties of undefined (reading ‘div’)
> TypeError: Cannot read properties of undefined (reading ‘div’)
> at Object.
anonymous (/Users/xxxx/neww/xxxx/node_modules/@sanity/ui/dist/index.js:1235:40)
AI Update

This is a known issue with @sanity/cli version 3.35.2 that's related to a styled-components peer dependency problem. The error occurs because version 3.35.2 introduced a requirement for styled-components v6, but your project likely has an older version installed or the dependencies weren't properly resolved during the update.

The Solution

Based on the community discussion, here's how to fix it:

  1. Update styled-components to version 6 in your package.json:

    "styled-components": "^6"
  2. Clean install your dependencies:

    # Delete your lock file and node_modules
    rm package-lock.json
    rm -rf node_modules
    
    # Reinstall everything
    npm install

The key here is doing a fresh npm install rather than npm update. Simply updating won't properly resolve the peer dependency tree, which is why you're seeing the "Cannot read properties of undefined (reading 'div')" error - @sanity/ui is trying to use styled-components methods that aren't available in older versions.

Why This Happened

The @sanity/cli 3.35.2 release updated its dependency on @sanity/ui, which in turn requires styled-components v6. If you had v5 installed, the package wasn't compatible, causing the bundled UI components to fail when trying to access styled-components' API.

Alternative Solution

If you're still experiencing issues after the clean install, you could temporarily downgrade to @sanity/cli 3.35.1 until you're ready to update all dependencies, though upgrading styled-components is the recommended long-term fix. The issue was resolved in subsequent CLI releases, so you might also consider updating to a newer version of @sanity/cli (3.35.3 or later) which should handle the styled-components dependency more gracefully.

Show original thread
12 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?