Issue with deploying GraphQL endpoint for Sanity Studio
3 replies
Last updated: May 10, 2024
L
✅ 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
/studio
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
require
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
v18.19.0
and you’ll find my dependencies’ details in the thread 💡 Thanks a lot for your help! 🙏
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
yarn.lock
and
node_modules
folder and reinstalling everything fresh with node 21, and now everything works fine 👌