✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Issue with deploying GraphQL endpoint for Sanity Studio

2 replies
Last updated: Mar 24, 2024
SOLVEDKeeping it if anybody runs into the same issue, solution in thread

Hi everyone
I’m writing because I’m struggling with deploying a GraphQL endpoint for my Sanity Studio.
I chose to self-host the studio in my project, so my application’s files are colocated with the ones for the studio, and the studio UI can be accessed at
from my main page.
I saw that the GraphQL endpoint was not automatically deployed when deploying the studio, and that I should run the
sanity graphql deploy
command.So I tried doing that, but I’m getting a weird error mentioning an ES modules issue:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/[...]/node_modules/string-width/index.js from /Users/[...]/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js to a dynamic import() which is available in all CommonJS modules.
I checked that I’m not using any
statement in my code and I followed all the tutorial steps, have read a lot of the docs and the forums but didn’t find any solution to this problem. Would anyone have an idea how to unblock me please? I’m using node
and you’ll find my dependencies’ details in the thread 💡
Thanks a lot for your help!
Mar 24, 2024, 6:06 PM
"dependencies": {
  "@sanity/client": "^6.12.4",
  "@sanity/icons": "^2.8",
  "@sanity/image-url": "1",
  "@sanity/types": "^3.25",
  "@sanity/ui": "^2.0",
  "@sanity/vision": "3",
  "clsx": "^2.1.0",
  "next": "^14.1",
  "next-sanity": "7.1.4",
  "react": "^18.2",
  "react-dom": "^18",
  "sanity": "^3.25",
  "styled-components": "^6.0"
Mar 24, 2024, 6:07 PM
After searching the Github forums of the faulty packages, I started meddling with the peer dependencies resolutions but it didn’t work, so I ended up deleting my
folder and reinstalling everything fresh with node 21, and now everything works fine 👌
Mar 24, 2024, 7:21 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?