Sanity init fails after updating to latest version
I understand you're hitting errors with sanity init after updating Sanity. Without seeing the specific error in your screenshot, the most likely culprit is Node.js version compatibility.
Check Your Node.js Version First
Sanity Studio v4 requires Node.js 20 or higher. This is a hard requirement introduced because Node.js 18 reached end-of-life in April 2024. Check your current version:
node -vIf you're on Node 18 or lower, that's almost certainly causing your sanity init failures. You'll need to upgrade to Node.js 20 or higher.
Why This Matters
When you updated Sanity with npm install --global sanity@latest, you likely pulled down Sanity v4, which won't run on older Node versions. The error might manifest as cryptic messages like crypto$2.getRandomValues is not a function or other initialization failures, regardless of which project name or dataset type you choose.
After Upgrading Node
Once you're on Node 20+, try sanity init again. The command should work normally and walk you through:
- Creating or selecting a Sanity project
- Setting up your dataset
- Choosing a project template
Alternative Installation Methods
If you continue having issues after confirming Node 20+:
- Clear npm cache:
npm cache clean --force - Reinstall Sanity CLI globally:
npm install --global sanity@latest - Try with npx (doesn't require global install):
npx sanity@latest init
Common Related Issues
The Node.js 20+ requirement is the only breaking change in Sanity Studio v4. If you have an existing v3 studio, the upgrade requires no code changes—just the Node version bump. This is why the version went from v3 to v4 despite no API changes: dropping Node version support is technically a breaking change under semantic versioning.
The fact that you're getting errors with different project names and dataset types points to an environmental issue (like Node version) rather than a configuration problem. Once your Node version is compatible, sanity init should work as expected.
Show original thread6 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.