dev" command not working despite Sanity being installed as dependency

15 replies
Last updated: Nov 29, 2025
Hiya! Just started my project and i have this error:Error: Command "dev" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
at CommandRunner.runCommand (~/Documents/GitHub/regi-khan/studio/node_modules/@sanity/cli/lib/_chunks/cli-0bbdf4ec.js
:17877:33701) at Object.runCli (~/Documents/GitHub/regi-khan/studio/node_modules/@sanity/cli/lib/_chunks/cli-0bbdf4ec.js
:17880:2456)
Don't understand, it defintely has sanity as a dependency....
AI Update

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 dev

2. 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 dev

4. 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 --cwd flag: 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 dev

The 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!

Show original thread
15 replies

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.

Was this answer helpful?