Studio crashes on /studio/desk in production but works locally

3 replies
Last updated: Aug 31, 2023
When I access /studio/desk in the production environment, the page crashes. But when I access this path in the local development environment, it works fine. Has anyone encountered this issue before? My Node.js version is 16.20.0.
AI Update

The crash you're experiencing with /studio/desk in production is likely related to your Node.js version being below the minimum requirement. Your Node.js 16.20.0 is below what Sanity Studio needs to run properly.

Understanding the Node.js Version Issue

According to the official Sanity documentation, Sanity Studio v3 requires Node.js 18 or higher, and Studio v4 requires Node.js 20 or higher. Node.js 16 reached end-of-life, and modern tooling that Studio depends on (like Vite) requires Node 18+ to function properly.

Why It Works Locally But Not in Production

This is the key to your issue - the fact that it works locally but crashes in production suggests an environment mismatch:

  1. Your local development environment may be using a different Node version than what you think. Check your actual running version with node -v in the terminal where you run npm run dev
  2. Your production environment is strictly enforcing Node 16.20.0, which causes the crash
  3. Development servers can sometimes be more forgiving with certain compatibility issues, or you might have a local Node version manager (like nvm) that's using a different version

About the "Workspace: missing context value" Error

The "Workspace: missing context value" error is a known issue that has appeared when embedding Studio into Next.js apps, particularly when there are version mismatches or build configuration issues. In that GitHub issue thread, users reported the same error with various Node versions, and it was often related to how the Studio was being bundled in production versus development.

How to Fix This

1. Upgrade your Node.js version in production:

For your production environment, you need to specify Node.js 18 or higher (20+ is recommended):

  • Vercel: Add to your package.json: "engines": { "node": "20.x" }
  • Netlify: Create a .nvmrc file with 20, or set NODE_VERSION=20 in environment variables
  • Other platforms: Check your hosting provider's documentation for specifying Node versions

2. Verify your local Node version:

Run node -v in your terminal to confirm what version you're actually using locally. If it's 18+, that explains why local works but production doesn't.

3. Update your local development environment:

Even though it works locally now, you should upgrade to Node 20+ to match production and ensure consistency:

# If using nvm
nvm install 20
nvm use 20

4. Clear build caches and reinstall:

After upgrading Node, clean your dependencies:

rm -rf node_modules .next
npm install
npm run build

Once you've upgraded Node.js in your production environment to version 20 or higher and redeployed, the /studio/desk route should work consistently across both environments.

Show original thread
3 replies
Are you running the latest version of the Studio?
When I upgraded to the latest version it worked fine
The official scaffolding may need to be updated

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?