Error reading sanity/cli after updating to version 3.35.2
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:
Update
styled-componentsto version 6 in yourpackage.json:"styled-components": "^6"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.
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.