Node.js update resolves error after Sanity upgrade in Slack thread
The error you're encountering is happening because you're running Node.js v16.20.0, but current versions of Sanity Studio require Node.js 18 or higher (and as of Studio v4, Node.js 20+ is required).
The crypto$2.getRandomValues is not a function error is a symptom of Vite (which Sanity Studio uses under the hood) trying to use crypto APIs that aren't available or are implemented differently in older Node.js versions.
Solution
You need to upgrade your Node.js version. Here's what to do:
Install Node.js 20 or higher (recommended to use the latest LTS version)
- Download from nodejs.org
- Or use a version manager like nvm (recommended for managing multiple Node versions)
Verify your Node version after installation:
node -vYou should see v20.x.x or higher
Reinstall your dependencies:
yarn installTry running dev again:
yarn dev
Why This Happened
When you ran yarn upgrade, it updated Sanity packages to newer versions that require Node.js 20+. As explained in Sanity's blog post about Studio v4, this requirement was introduced because Node.js 18 reached end-of-life in April 2024, and the upgrade allows Sanity to use modern tooling like Vite 7 for faster builds and better performance.
The good news is that once you upgrade Node.js, everything should work smoothly!
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.