Error running "dev" command in Sanity project
This error happens when you're running the sanity dev command from the wrong directory. Even though you have Sanity installed as a dependency, the CLI needs to be executed from the actual Sanity project folder.
Here are the most common causes and fixes:
1. Wrong directory (most likely)
Make sure you're running the command from inside the studio folder. Based on your error path, you should be in:
cd ~/Documents/GitHub/regi-khan/studio
sanity dev2. Missing sanity.config.ts/js
The CLI looks for a Sanity config file to confirm it's in a project context. Verify you have a sanity.config.ts (or .js) file in your studio directory.
3. Corrupted node_modules Sometimes the dependency installation gets messed up. Try:
cd studio # or your project folder
rm -rf node_modules
npm install
# or yarn install / pnpm install
sanity dev4. Running from monorepo root If you're in a monorepo setup and trying to run commands from the root, you have two options:
- Navigate into the studio folder first (recommended)
- Use the
--cwdflag:sanity dev --cwd ./studio
5. Global vs local CLI If you have the Sanity CLI installed globally but your project uses a different version locally, this can cause issues. Always use the local version:
npx sanity dev
# or if using npm scripts
npm run devThe most likely culprit based on your path structure (~/Documents/GitHub/regi-khan/studio/node_modules/...) is that you're running the command from the parent regi-khan directory instead of from inside the studio folder. Try cd studio first and then run sanity dev again!
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.