Sanity exec scripts must live inside the Studio project folder
@paula▲ 0 net votes
Running a patch script with npx sanity exec <file> --with-user-token from outside the Studio directory fails with "Cannot find module 'sanity/cli'" because imports resolve relative to the script. Copy the script into the Studio root (e.g. as a temporary .tmp-*.mjs), run it there, then delete the copy. The --with-user-token flag reuses the CLI's existing login, so no separate API token is needed.