Issue with compiling Sanity after updating Mac OS, resolved by upgrading Studio version.

7 replies
Last updated: Nov 23, 2022
Hi all! I regrettably updated my Mac OS from 12.6 to 13 yesterday, which seems to have impacted my Sanity dev environment. Now, when compiling Sanity errors out with the information below. Has anyone else run into this and if so how did you resolve? Thanks in advance!

✔ Compiling...
Failed to compile.

Error in ./node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
Module parse failed: Unexpected token (313:11)
You may need an appropriate loader to handle this file type.
|   }
| 
|   return { ...rect,
|     x: rect.x - scroll.scrollLeft + offsets.x,
|     y: rect.y - scroll.scrollTop + offsets.y
 @ ./node_modules/sanity-plugin-order-documents/node_modules/react-select/dist/react-select.esm.js 24:0-26
 @ ./node_modules/sanity-plugin-order-documents/build/components/organisms/TypeSection.js
 @ ./node_modules/sanity-plugin-order-documents/build/components/OrderDocuments.js
 @ ./node_modules/sanity-plugin-order-documents/build/index.js
 @ ./node_modules/@sanity/vision/lib/VisionTool.js (all:part:@sanity/base/tool)
 @ ./node_modules/@sanity/default-layout/lib/util/getRegisteredTools.js
 @ ./node_modules/@sanity/default-layout/lib/router.js
 @ ./node_modules/@sanity/default-layout/lib/Root.js (part:@sanity/base/root)
 @ ./node_modules/@sanity/base/lib/components/SanityRoot.js (part:@sanity/base/sanity-root)
 @ ./node_modules/@sanity/server/lib/browser/entry-dev.js
 @ multi ./node_modules/@sanity/server/lib/browser/entry-dev.js
AI Update

This error is related to webpack in Sanity Studio v2 having trouble transpiling modern JavaScript syntax (specifically the object spread operator ...rect) from the @floating-ui/dom package, which is a dependency of react-select, which in turn is being pulled in by the sanity-plugin-order-documents plugin.

The macOS upgrade likely updated your Node.js version or changed how npm resolves dependencies, causing newer versions of these packages to be installed that use syntax Studio v2's webpack configuration doesn't automatically transpile from node_modules.

Option 1: Clear and reinstall dependencies

Sometimes dependency resolution issues can be fixed by clearing your cache and reinstalling:

rm -rf node_modules package-lock.json
npm install

If you're using yarn:

rm -rf node_modules yarn.lock
yarn install

Option 2: Check your Node.js version

Studio v2 has specific Node.js version requirements. Check what version you're running:

node -v

If your macOS update changed your Node version, you may need to use a Node version manager (like nvm) to switch to a compatible version. Studio v2 typically works best with Node 14-16.

Option 3: Update or remove the problematic plugin

The sanity-plugin-order-documents plugin may need updating or could potentially be replaced with Studio v3's built-in ordering capabilities if you migrate. Check if there's a newer version available:

npm outdated

If the plugin isn't critical to your workflow, you could temporarily remove it to get unblocked:

  1. Remove it from your sanity.json plugins array
  2. Remove it from package.json dependencies
  3. Run npm install again

Option 4: Migrate to Studio v3 (Long-term solution)

Studio v3 uses Vite instead of webpack and handles modern JavaScript much better. While this is a bigger undertaking, it's worth considering since Studio v2 is no longer actively maintained. Studio v3 also has better built-in document ordering features that might replace your need for the plugin entirely.

Immediate Next Steps

I'd recommend trying these in order:

  1. Clear your dependencies and reinstall (Option 1)
  2. Verify your Node.js version is compatible with Studio v2 (Option 2)
  3. If still broken, temporarily remove the plugin to unblock development (Option 3)
  4. Plan a migration to Studio v3 when feasible (Option 4)

The core issue is that Studio v2's build system wasn't designed to handle the modern JavaScript syntax that newer npm packages use, which is why upgrading to Studio v3 is the most future-proof solution when your schedule allows.

What version of the Studio are you running?
Hi
user M
! Here’s the output of `sanity versions`:
@sanity/cli                   2.35.0 (up to date)
@sanity/base                  2.33.3 (latest: 2.35.0)
@sanity/core                  2.35.0 (up to date)
@sanity/default-layout        2.33.3 (latest: 2.35.0)
@sanity/default-login         2.33.3 (latest: 2.35.0)
@sanity/desk-tool             2.33.3 (latest: 2.35.1)
@sanity/eslint-config-studio   2.0.0 (up to date)
@sanity/vision                2.33.3 (latest: 2.35.0)

Ah, yes, this was a bug in a previous version. Can you try upgrading your Studio? Please let me know if that doesn't fix it, though!
OK, will try that - thank you!
user M
that solved my issue, thanks again
Fantastic!
user M
We are running Studio v 2.33.3 with the Media Browser plugin and getting this same error. We had to remove the Media Browser to get the Studio to run again. At the moment we replaced the Media Browser with Media Library plugin.

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?