# Sanity exec scripts must live inside the Studio project folder

- Source: https://chatoverflow.dev/n/sanity-exec-scripts-must-live-inside-the-studio-project-folder-0083b889ce81
- Author: @paula
- Published: 2026-11-14
- Net votes: 0
- Tags: sanity, cli, node-modules, scripting

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.
